It was based upon three of C. S. Forester's Horatio Hornblower novels, The Happy Return (Beat to Quarters in the United States), A Ship of the Line, and Flying Colours. Forester is credited with the adaptation; as a result, the film is faithful to his novels and features an occasionally introspective tone unusual for an old-fashioned swashbuckler.
"In the year eighteen hundred and seven, a small ship of the Royal Navy set sail from England for a secret destination. With five million French and Spanish soldiers poised on the Continent under Napoleon, nothing could save England from invasion except her 300 ships.
"HMS Lydia'' was soon far beyond battle-charged Europe. Under the most secret of sealed orders, she sailed for southern waters, fought her way around the Horn... headed north again into the Pacific.
For seven months, she stayed out of sight of land. Becalmed finally, her weary crew toiled at the oars in the vain hope of towing her into a wind. They thirsted and hungered and wondered where she was going, what they would do when they got there... if she got there.
"These were things known only to one man."
That man is Captain Horatio Hornblower (Gregory Peck) commanding the 36-gun frigate HMS Lydia. His mission is to provide arms and support to the megalomaniac calling himself "El Supremo" or "The Almighty" (Alec Mango) in his rebellion against Spain, an ally of Britain's enemy France during the Napoleonic Wars. As Hornblower noted to First Lieutenant Bush (Robert Beatty): "War breeds strange allies, Mr. Bush."
Upon his arrival, the Englishman is told that a larger, much more powerful Spanish warship, the 50-gun Natividad, has been sighted. When it anchors nearby, Hornblower and his crew board and capture it in a surprise night-time attack. He then reluctantly hands the ship over to El Supremo to appease the madman and they go their separate ways.
Later, he encounters a small Spanish vessel with a pair of troublesome passengers. First, a Spanish official informs him (and provides proof) that Spain has switched sides. Then Lady Barbara Wellesley (Virginia Mayo) "requests" passage back to England for her and her maid. Due to a deadly epidemic raging ashore and her influential relations (she is the fictitious sister of Arthur Wellesley, the future Duke of Wellington), Hornblower is in no position to refuse, even though he has to find and sink the Natividad. Using masterful tactics, he accomplishes his mission. On the voyage back to England, Lady Barbara falls ill (of what Hornblower mistakenly believes is yellow fever) and is nursed back to health by him. They spend many enjoyable nights talking and playing whist, and fall in love, but he rejects her advances as he is married, to her embarrassment.
After arriving home, he learns that his wife Maria has died. Hornblower is given command of the Sutherland, a powerful ship of the line captured from the French, and is assigned to a squadron commanded by Rear Admiral Sir Rodney Leighton (Denis O'Dea), Lady Barbara's pompous new husband. The squadron's mission is to enforce the British blockade against Napoleonic France.
At a conference on Leighton's flagship, Hornblower urges a wide deployment to counter any sortie of the French Navy in support of Napoleon's land campaign on the Spanish penisula. However, a suspicious Leighton expressly forbids Hornblower from taking any independent action without his permission.
Hornblower's French-built ship is subsequently mistaken for a friendly vessel by a French ship, making for its easy capture. While interrogating a disguised French diplomat, Hornblower learns the enemy's recognition signal for the day, as well as vital intelligence that four French ships of the line have slipped the British blockade and are heading to Spain, carrying troops and supplies to the French armies there. Faced with the urgency of the situation, Hornblower decides on his own initiative to attempt to find and sink the ships. He locates them anchored in a harbor guarded by a well-armed fort. By flying a French flag and the recognition signal, as well as taking advantage of the appearance of Sutherland's French-built design, Hornblower fools the French garrison into believing the Sutherland is a French ship-of-the-line, enters the harbor unhindered, and manages to sink or damage all four anchored ships. The French fort then opens fire, and Hornblower, First Lieutenant Bush, and the rest of the crew abandon ship, after deliberately sinking the Sutherland in the harbor channel. Hornblower's actions made sure that the damaged French vessels in the harbor were now trapped "Like ships in a bottle" and vulnerable to the approaching British squadron.
The rest of the British squadron arrives shortly afterwards to complete the job; Leighton is killed in the resulting battle. Hornblower and Bush, accompanied by seaman Quist (James Robertson Justice), are taken by carriage to Paris to be tried on the trumped-up charge of espionage. They manage to escape en route and make their way to a port. Disguised as Dutch officers, they board The Witch of Endor, a captured British ship, overpower the skeleton crew, free a working party of British prisoners of war to man her, and sail away to freedom.
At his mandatory court-martial, Hornblower is acquitted and becomes a national hero. With Maria and Lady Barbara's husband both deceased, the two lovebirds are reunited.
The film made its world-wide premiere in New York City on September 13, 1951.