In 1880 Buchanan unsuccessfully contested Haddington in the 1880 general election but was successfully returned to Parliament for Edinburgh in an 1881 by-election.
Buchanan lost the Edinburgh West seat in 1892 but returned to the House of Commons in December the same year when he was elected to represent Aberdeenshire East in a by-election.
When the Liberals came to power in December 1905, he was appointed Financial Secretary to the War Office by Prime Minister Sir Henry Campbell-Bannerman, a post he retained until April 1908.
The latter month he was sworn of the Privy Council and made Under-Secretary of State for India by the new Prime Minister, H. H. Asquith.
He died on 7 April 1911 in Bournemouth in Hampshire and was buried in the churchyard of St Bartholomew's Church at Arborfield in Berkshire where his sister lived.