The Second Battle of Algeciras (also known as the Battle of the Gut of Gibraltar) was a naval battle fought on the night of 12 July 1801 between a squadron of British Royal Navy ships of the line and a larger squadron of ships from the Spanish Navy and French Navy in the Gut of Gibraltar. The battle followed closely the First Battle of Algeciras on 6 July, in which a French squadron anchored at the Spanish port of Algeciras was attacked by a larger British squadron based at nearby Gibraltar. In a heavy engagement fought in calm weather in the close confines of Algeciras Bay, the British force was becalmed and battered, suffering heavy casualties and losing the ship HMS Hannibal. Retiring for repairs, both sides called up reinforcements, the French receiving support first, from the Spanish fleet based at Cadiz, which sent six ships of the line to escort the French squadron to safety.

Arriving at Algeciras on 9 July, the combined squadron was ready to sail again on 12 July, departing Algeciras to the westwards during the evening. The British squadron under Rear-Admiral Sir James Saumarez, having effected its own hasty repairs, set off in pursuit. Finding that his ships were falling behind, Saumarez instructed his captains to separate and attack the combined squadron as best they were able to. The fastest ship was HMS Superb under Captain Richard Goodwin Keats, which sailed through the Spanish rearguard as a moonless night fell. Superb fired on the rearmost ships, setting the 112-gun Real Carlos on fire and capturing the Saint Antoine. Unable to determine friend from foe in the darkness, Real Carlos inadvertently engaged the Spanish ship San Hermengildo, spreading the fire to its compatriot. Both ships subsequently exploded with enormous loss of life. A second stage of the battle then developed, as HMS Venerable took the lead of the British line, attacking the rearmost French ship Formidable under Captain Amable Troude. In a furious and protracted engagement, Venerable suffered heavy damage and was driven ashore, allowing the remainder of the French force to return to Cadiz without further fighting.

In the aftermath of the action, Venerable was towed off the shoreline and back to Gibraltar for repairs, while the remainder of the British squadron restored the British blockade of the French and Spanish ships in Cadiz, returning the situation to that in place before the battle. This British victory, coming so soon after Saumarez's defeat in Algeciras harbour, did much to restore parity in the region and the heavy casualties inflicted on the Spanish were to contribute to a weakening of the Franco-Spanish alliance which was a contributory factor in the signing of Treaty of Amiens, which brought the war to a temporary halt early the following year. In France, despite the heavy Spanish losses, the battle was celebrated as a victory, with Troude widely praised and promoted for the defence of his ship.