On 22 July 1805, Stirling took part in the Battle of Cape Finisterre under Sir Robert Calder, during which his squadron attacked the combined French and Spanish fleets off Cape Finisterre. In July 1806 he was given command of the ship and order to convoy General Samuel Auchmuty's troops to Buenos Aires, where he would relieve Admiral Sir Home Riggs Popham, who, with troops under William Carr Beresford, had captured Buenos Aires in the first of a series of British invasions of the Río de la Plata. By the time he arrived, Buenos Aires had been retaken by the Spanish, so after relieving Popham and transferring to Popham's ship, , Stirling aided Auchmuty in a successful attack on Montevideo. He was later praised in both Houses of Parliament and in the British press for his good judgement.