Marryat was born in London, the son of Joseph Marryat, a "merchant prince" and member of Parliament and his American wife Charlotte, née von Geyer. After trying to run away to sea several times, he was permitted to enter the Royal Navy in 1806, as a midshipman on board HMS Imperieuse, a frigate commanded by Lord Cochrane (who would later serve as inspiration for both Marryat and other authors).
Marryat's time aboard the Imperieuse included action off the Gironde, the rescue of a fellow midshipman who had fallen overboard, captures of many ships off the Mediterranean coast of Spain, and the capture of the castle of Montgat. When the Imperieuse shifted to operations in the Scheldt, in 1809, Marryat contracted malaria, and returned to England on the 74-gun HMS Victorious.
After recuperating, Marryat returned to the Mediterranean in the 74-gun HMS Centaur, and again saved a shipmate by leaping into the sea after him. He then sailed as a passenger to Bermuda in the 64-gun HMS Atlas, and from thence to Halifax, Nova Scotia on the schooner HMS Chubb. Once there he joined the 32-gun frigate HMS Aeolus, on 27 April 1811.
A few months later, Marryat again earned distinction by leading the effort to cut away the Aeolus' mainyard to save the ship during a storm, and, continuing a pattern, he also saved one of the men from the sea. Shortly thereafter, he moved to the frigate HMS Spartan, participating in the capture of a number of American ships (the War of 1812 having begun by then), and on 26 December 1812 was promoted to lieutenant.
As lieutenant, Marryat served in the sloop HMS Espiegle and in HMS Newcastle, and was promoted to commander on 13 June 1815, just in time for peace to break out. He then pursued scientific studies, invented a lifeboat (thus earning both a gold medal from the Royal Humane Society and the nickname 'Lifeboat'). Based on his experience in the Napoleonic Wars escorting merchant ships in convoys, he developed a practical and widely used system of maritime flag signalling known as Marryat's Code.