In 1807, at the outset of the Peninsular War, Napoleonic forces invaded Portugal due to the Portuguese alliance with Great Britain. The prince regent of Portugal at the time, John VI, had formally governed the country on behalf of Maria I of Portugal since 1799. Anticipating the invasion of Napoleon's army, John VI ordered the transfer of the Portuguese royal court to Brazil before he could be deposed. Setting sail for Brazil on November 29, the royal party navigated under the protection of the British Royal Navy, and eight ships of the line, five frigates, and four smaller vessels of the Portuguese Navy, under the command of Admiral Sir Sidney Smith. On December 5, almost halfway between Lisbon and Madeira, Sidney Smith, along with Britain's envoy to Lisbon, Lord Strangford, returned to Europe with part of the British flotilla. Graham Moore, a British sailor and career officer in the Royal Navy, continued escorting the Portuguese royal family to Brazil with the ships "Marlborough", "London", "Bedford", and "Monarch".