Fifth son of the 10th Lord Elphinstone, he was born in Elphinstone Tower, near Stirling, Scotland. Two of his brothers went to sea, and he followed their example by entering the Royal Navy in 1761, in HMS Royal Sovereign but then transferred to
, then commanded by Captain John Jervis, afterwards Earl Saint Vincent. In 1767, he made a voyage to the East Indies in the British East India Company's service, and put £2000 lent him by an uncle to such good purpose in a private trading venture that he laid the foundation of a handsome fortune. He became lieutenant in 1770, commander in 1772, and post captain in 1775.
During the war in America he was employed against the privateers, and with a naval brigade at the occupation of Charleston, South Carolina. In January 1781, when in command of the 50-gun
, he captured a Dutch 50-gun ship which had beaten off a British vessel of equal strength a few days before. On 15 September 1782 in the Delaware Bay he led a squadron that captured the French 38 gun frigate Aigle during which Captain Latouche Tréville was taken prisoner. After peace was signed he remained on shore for ten years, serving in Parliament as member first for Dunbartonshire, and then for Stirlingshire. He was elected a fellow of the Royal Society in 1790.
When war broke out again in 1793, he was appointed to the 74-gun HMS Robust, in which he took part in the occupation of Toulon by Samuel Hood, 1st Viscount Hood. He particularly distinguished himself by beating a body of the French ashore at the head of a naval brigade of British and Spaniards. He was entrusted with the duty of embarking the fugitives when the town was evacuated. In 1794 he was promoted rear-admiral, and in 1795 he was sent to occupy the Dutch colonies in South Africa thereby establishing the Cape of Good Hope Station. He had a large share in the capture of the Cape in 1795, and in August 1796 captured a whole Dutch squadron in Saldanha Bay. In the interval he had gone on to India, where his health suffered, and the capture at Saldanha was effected on his way home. When the Nore Mutiny broke out in 1797 he was appointed to the command, and was soon able to restore order. He was equally successful at Plymouth, where the squadron was also in a state of effervescence.
At the close of 1798, he was sent as second in command to St Vincent. It was for a long time a thankless post, for St Vincent was at once half incapacitated by ill-health and very arbitrary, while Horatio Nelson, who considered that Keith's appointment was a personal slight to himself, was peevish and insubordinate. In May 1799, he was unable to counter Bruix' expedition, mainly due to sparring among the British naval commanders. Keith followed the enemy to Brest on their retreat, but was unable to bring them to action.
He returned to the Mediterranean in November as commander-in-chief. He co-operated with the Austrians in the siege of Genoa, which surrendered on 4 June 1800. It was however immediately afterwards lost in consequence of the Battle of Marengo, and the French made their re-entry so rapidly that the admiral had considerable difficulty in getting his ships out of the harbour. The close of 1801 and the beginning of the following year were spent in transporting the army sent to recover Egypt from the French. As the naval force of the enemy was completely driven into port, the British admiral had no opportunity of an action at sea, but his management of the convoy carrying the troops, and of the landing at Aboukir, was greatly admired.
He was made Baron Keith of the United Kingdom, an Irish barony having been conferred on him in 1797. On the renewal of the war in 1803 he was appointed Commander-in-Chief, North Sea (which at the time included Nore Command), which post he held till 1807. In February 1812 he was appointed commander-in-chief in the English Channel, and in 1814 he was raised to a viscounty. During his last two commands he was engaged first in overlooking the measures taken to meet a threatened invasion, and then in directing the movements of the numerous small squadrons and private ships employed on the coasts of Spain and Portugal, and in protecting trade.
He was at Plymouth when Napoleon surrendered and was brought to England in HMS Bellerophon by Captain Maitland (1777–1839). The decisions of the British government were expressed through him to the fallen Emperor. Lord Keith refused to be led into disputes, and confined himself to declaring steadily that he had his orders to obey. He was not much impressed by the appearance of his illustrious charge and thought that the airs of Napoleon and his suite were ridiculous. Lord Keith died in 1823 at Tulliallan Castle, near Kincardine-on-Forth, Fife, his property in Scotland, and was buried in the parish church.