He stood unsuccessfully as an SNP candidate for the House of Commons in the Glasgow Anniesland constituency in the 1997 General Election before standing in the Glasgow Maryhill constituency in both the 1999 and 2003 Scottish Parliamentary elections. Wilson was also elected chair of the SNP's Glasgow Regional Association in 2001. In the aftermath of the SNP's poor election performance in 2003, Wilson became convinced that a change of direction was needed by the SNP leadership. After discussing this with various SNP members, he was persuaded to contest the leadership himself and launched a challenge against the SNP leader, John Swinney. His campaign focused on the issue of centralising the control of the party away from the branches and activists, and what he argued was the trend of placing the SNP ideologically in the centre ground of politics, away from the party's traditional position on the left-of-centre. In the leadership contest that ensued at the SNP's 2003 Conference Swinney received 577 votes from those delegates voting to Wilson's 111 to remain leader. There were 17 "positive abstentions" and 60 non-voters. However, the following year Swinney resigned after sustained media speculation that he was unsuitable for the role. The immediate catalyst for Swinney's resignation was the SNP's poor performance in the elections to the European Parliament, although many spectators commented that Wilson's challenge also contributed to his resignation. Shortly after the leadership contest he stood down as convenor of the SNP Glasgow Regional Association and was replaced in that position by his leadership campaign manager. Wilson stood as the SNP candidate for the Paisley and Renfrewshire North constituency for the 2005 UK general election. He finished in second place behind James Sheridan of the Labour Party.
As an MSP
At the 2007 Scottish Parliament election, Wilson stood in the West Renfrewshire constituency and also on the party list for the West of Scotland region. In West Renfrewshire he came third, the SNP dropping behind the Conservatives who took second place to Labour. He was elected on the regional list and sworn in as a Member of the Scottish Parliament. to the Scottish Parliament, delivered on 6 June 2007, underlined his belief in the links between crime and deprivation and his commitment to social justice. His campaigns have included awareness of the negative health impact of depleted uranium on service personnel and civilians, equity fines for corporate crimes, as well as promotion of Scots language.
Joining the Scottish Greens
Following the 2017 General Election campaign Wilson left the SNP and subsequently joined the Scottish Green Party. On 28 June 2018 he was elected Co-Convener of the Edinburgh Branch of the Scottish Greens.