Anderson was born at Coupar Angus in 1862, the eldest son of Charles Enverdale Anderson, Provost of Coupar Angus. He was educated at the High School of Dundee and Edinburgh University where he graduated with MA and LL.B degrees. He received a distinction in law and was awarded the Forensic Prize as the most distinguished law graduate of his year. In 1901, he married Agnes Catherine ("Kate") Mackay from Midlothian. They had two sons and two daughters.
Anderson was called to the Scottish bar in 1889 and established a large practice as an advocate particularly in jury cases. He was made an Advocate Depute in 1906 and took silk in 1908. From December 1911 to October 1913 he held the post of Solicitor General for Scotland. In 1913, he was appointed a Senator of the College of Justice to replace the retired Lord Kinnear and took the judicial title of Lord Anderson.
Anderson was selected as Liberal candidate for North Ayrshire in December 1905 to contest the 1906 general election. He faced the sitting Unionist MP, Thomas Cochrane. At the previous general election in 1900, there had been a straight fight between Unionist and Liberal candidates but in 1906 Labour also stood a candidate, James Brown. This had the effect of splitting the anti-Unionist vote and Cochrane held his seat with a majority of 1,016 votes over Anderson.
Anderson fought in Ayrshire North again at the general election of January 1910. He again faced Cochrane and Brown as his opponents but this time the Labour vote declined and Anderson reaped the advantage. He gained the seat from Cochrane by a majority of 238 votes.
At the general election held in December 1910, Anderson retained his seat, this time in a straight with a new Unionist candidate, Captain Duncan Campbell, and, against the general trend in Scotland, slightly increased his majority to 354 votes.
In December 1911, Anderson was appointed Solicitor General for Scotland, a law officer of the Crown. In accordance with the constitutional arrangements of the day, he was obliged to resign as an MP and fight a by-election. The contest, which took place on 20 December 1911, was dominated by the government's legislation on National Insurance and the uncertainties this legislation would produce for individual electors, particularly those of small manufacturers and shopkeepers. Although there was no Labour candidate, Anderson was thought to have lost some support among working-class voters because of his opposition to Labour candidates in other recent elections. Anderson's Unionist opponent was again Duncan Campbell. After another tight contest, Campbell recaptured the seat for the Tories by a majority of 271 votes. After six years of Liberal government, the electors of North Ayrshire reverted to their more traditional allegiances, perhaps rebelling against the background of the rapid social changes being introduced by H H Asquith's reforming administration.
After the election, Anderson agreed to be re-adopted as prospective Liberal candidate for North Ayrshire, expressing a wish to contest the seat again. However the seat disappeared in boundary changes for the 1918 general election and Anderson did not contest any of the successor seats. He did not stand for the House of Commons again.
Anderson was sometime Deputy Lieutenant for the County of the City of Edinburgh. He was awarded an Honorary Doctorate of Laws by Edinburgh University and he also received a similar degree from Aberdeen University in 1924. He was Chairman of the Scottish Committee on Aliens, 1917–18 and, more prosaically, was Chairman of the Committee on Glasgow Market Lettings in 1933.
Anderson was a keen sportsman. In addition to the usual gentleman's pastimes of the day such as fishing and golf, he also enjoyed curling and had been a useful footballer in his youth both for Edinburgh University and for the well-known amateur side Queen's Park.
Anderson died aged 73 at home, 9 Great King Street in Edinburgh late on the evening of Wednesday 27 May 1936 from bronchial pneumonia. Despite having been unwell for some time he persevered with his duties on the bench until a few days before he died.
He is buried against the north wall of the 20th century extension to Dean Cemetery in western Edinburgh with his wife, Agnes Catherine MacKay (d.1952).The Criminal Law of Scotland, Bell & Bradfute, Edinburgh 1892 and 2nd edn, 1904