A spell in captivity and first commands
The combined fleets of France and Spain were retiring from the Mediterranean by mid-1799, and on 7 July St Vincent ordered Maitland to go aboard the hired armed cutter Penelope with orders for her to carry out reconnaissance on the enemy fleets, as St Vincent put it, "to go, count and dodge them". When Maitland arrived however, he found out that Penelope's lieutenant was sick and unable to take command. Maitland took over instead and attempted to follow his orders. He was apparently hampered by the cowardice and disobedience of the crew of the cutter, and the next day the Spanish captured Penelope and brought her into Cádiz as a prize. There Maitland met Lieutenant-general Jose de Mazarredo y Salazar. Mazarredo discovered that Maitland was Lord St Vincent's flag lieutenant. Being under an obligation to St Vincent, Mazarredo set Maitland free and returned him to Gibraltar without requesting an exchange.
On his return, St Vincent promoted Maitland to commander and gave him the sloop HMS Cameleon, with the promotion being backdated to 14 June. Maitland commanded her off the coast of Egypt, under Sir Sidney Smith until the signing of the Convention of El Arish on 24 January 1800. Maitland was sent home overland with dispatches, but quickly returned to his command. He spent the rest of 1800 aboard the Cameleon, before Lord Keith moved him to the command of the storeship HMS Wassenar. The Wassenar was at that time moored at Malta, and had been deemed unfit for service. Maitland was given permission instead to accompany the expedition to Egypt. He was appointed to command the boats that were covering the landings and acquitted himself well. He then moved to support the army's right flank during operations on 13 March, and at the Battle of Alexandria on 21 March 1801. His service was specially acknowledged by the commanders-in-chief, and he was mentioned in Sidney Smith's report. These actions caused him to be rewarded with a promotion to post rank, dated to 21 March. He temporarily took command of the 74-gun HMS Dragon, but had moved to command HMS Carrere in August. He returned with her to England, and she was paid off in October 1802.