1906 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.
1910 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 fight with a new Unionist candidate,
Captain Duncan Campbell, and, against the general trend in Scotland, slightly increased his majority to 354 votes.
North Ayrshire by-election, 1911 In December 1911, Anderson was appointed
Solicitor General for Scotland, 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. ==Appointments and honours==