Flanagan served as a member of Roscommon County Council between 2004 and 2011. First elected at the 2004 local election, he was re-elected in 2009, and served as mayor from 2010 until his election as a Teachta Dála (TD) for the Roscommon–South Leitrim constituency at the 2011 general election. He served in Dáil Éireann for three years before being elected as an independent candidate for the Midlands–North-West constituency at the 2014 European Parliament election. Flanagan is a social campaigner best known for his long-running involvement in the campaign for the legalisation of cannabis and addressing allegations of corruption in the Garda Síochána, the national police force.
Flanagan has been convicted on several occasions of possession of cannabis for personal use. He served nine days of a 15-day sentence at Loughan House open prison in County Cavan in 1998, for refusing to pay a fine imposed for breach of the Litter Pollution Act.
Flanagan began his political career running unsuccessfully as an independent candidate in the Galway West constituency at the 1997 general election. He entered politics urging the legalisation of cannabis and as a protest candidate against his landlord, Fianna Fáil TD Frank Fahey. He got 548 votes (1.1%). He went on to contest the Connacht–Ulster constituency at the 1999 European Parliament election receiving 5,000 votes (1.6%) and the Longford–Roscommon constituency at the 2002 general election receiving 779 votes (1.6%).
He was not portrayed by the media as a serious candidate, shaving his hair and styling his beard in the way of Ming the Merciless from the comic strip Flash Gordon. His posters and other election material featured cannabis leaves, and legalisation of the drug was one of his main policy platforms. He voiced uncompromising support for radical social and environmental issues, and displayed a knack for using the media, being featured in many newspapers and radio programmes who were attracted by his colourful appearance and strong rhetoric.
In 2001, he hit the headlines when he sent more than 200 cannabis cigarettes to politicians in the Oireachtas, one to each TD and senator, as part of his campaign to have cannabis legalised.
Flanagan returned to his native Castlerea in County Roscommon where he contested the 2004 local elections; he was elected to Roscommon County Council, topping the poll and being elected on the first count, defeating sitting councillors John Murray and Danny Burke. He was re-elected on the first count at 2009 local elections, receiving 16.8% of 1st preference votes in the Castlerea electoral area, and exceeding the quota by 394 votes.
On 28 June 2010, Flanagan was elected as the Mayor of Roscommon County Council. On 27 July 2010, Flanagan was the subject of debate over refusing to lead the prayer said before council meetings, because as a non-believer he said it would be hypocritical. The matter was later resolved by asking the Deputy Mayor Ernie Keenan to say the prayer.
In December 2010, Flanagan proposed that his Mayoral allowance should be halved, and many of his other allowances be abolished entirely, in recognition of the financial difficulties that the country and the county were experiencing. The proposal met with a mixed reception from his council colleagues.
Flanagan was elected to represent the Roscommon–South Leitrim constituency in the 31st Dáil in the 2011 general election, one of twenty members of the New Vision alliance of independent candidates. He received 8,925 (18.8%) first preference votes, and was elected to the first seat with 12,149 votes on the fourth count, while the two incumbent Fine Gael TDs were elected on the sixth count. Neither of the two Fianna Fáil candidates managed to retain the seat of their retiring party colleague, Michael Finneran.
Upon election, Flanagan took a 50% salary cut and urged his fellow TDs to follow suit. Following his election to the Dáil, Flanagan nominated independent John Murphy to replace him on Roscommon County Council.
When he was elected in 2011, Flanagan kept his promise to retain only half of his €92,672 salary and distribute the rest to local projects. He refused to hand it back to the State, claiming it would only be pumped into the banks.
In March 2011, one month after being elected to Dáil Éireann, Flanagan announced that he would cease his smoking of cannabis while in Ireland in order to protect his family and focus on the issues for which he stands. He said he still intended to smoke cannabis when abroad. This followed a formal complaint lodged to the Garda Síochána by a Fianna Fáil councillor from Kilkenny about his cannabis use. Flanagan said that: "...my wife and children are the most important people on the planet to me and I don't want my kids to witness the Garda calling to the house." He said he would continue to campaign for the legalisation of cannabis.
In July 2011, Flanagan was linked to an incident in which a Dáil microphone picked up a conversation he had with fellow independent TDs Shane Ross and Mick Wallace. During the exchange the trio appeared to be disparaging the appearance of Fine Gael TD Mary Mitchell O'Connor. Wallace initiated the conversation by saying "Miss Piggy has toned it down a bit today". Flanagan was heard saying "they’d want to ban her wearing pink" and Ross commented that "she normally wears the most garish colours".
On 2 November 2011, Flanagan walked out of the Dáil amid a heated disagreement with Minister for Agriculture Simon Coveney over turf-cutting rights. Flanagan had observed that his Fine Gael constituency colleague Frank Feighan had promised before the 2011 general election that he would "sign his name in blood" if that was required to oppose a turf-cutting ban, with Coveney responding by saying populism was a dangerous thing. Flanagan then said, "Populism and bondholders. I am leaving the chamber", with Coveney telling him to "go on and walk out in protest". Flanagan retorted, "My daddy did not give me a seat." This referred to the fact that Simon Coveney was elected in a by-election after his father, Hugh Coveney TD died in an accident in March 1998.
On 15 December 2011, Flanagan helped launch a nationwide campaign against a proposed household charge being brought in as part of the 2012 Irish budget.
In April 2012, Flanagan stated he would be urging people to vote 'No' in the referendum on ratification of the European Fiscal Compact Treaty on the grounds that Ireland would lose power to bigger countries in Europe. He also stated that Ireland should leave the economic and monetary union (EMU), based on the euro currency.
Flanagan admitted to "atrocious" timing after calling gardaí "corrupt" on television, as thousands of people gathered for the state funeral of murdered garda Adrian Donohoe in Dundalk, County Louth, in January 2013. In early March 2013, the Sunday Independent's Daniel McConnell reported that Flanagan had been issued with a fine of €60 and two penalty points on his driving licence for operating a mobile phone while driving in June 2011. According to these reports, Flanagan then had his punishment rescinded at a later date with a claim of being on 'Dáil business'. The stories caused controversy at the time as Flanagan, with other independent TDs, had been involved in a campaign highlighting the cancellation of 197 Fixed Charge Notices out of the 1.4 million issued, which it was alleged were 'inappropriately' quashed. In the Dáil, Flanagan admitted he twice had penalty points cancelled, though he also asked that they be reinstated.
In June 2013, Flanagan came to prominence as an advocate of turf cutters whose ability to cut turf (peat) was affected by the European Union's Habitats Directive. As part of his advocacy, Flanagan attended a number of turf cutters' protests. Flanagan supports the cutting of turf from bogs even when they are protected as Special Areas of Conservation. Despite a European Union ban, he has cut turf at Cloonchambers Bog near Castlerea, a raised bog which has been designated a Special Area of Conservation.
On 21 March 2014, Flanagan announced that he would run as an independent candidate for the Midlands–North-West constituency at the 2014 European Parliament election. He ran on an "anti-European Union platform". During the campaign he famously said, "I'm sick and tired of dealing with the monkey, I want to go and deal with the organ grinder." He was elected at the second count on 26 May 2014 after being deemed to have passed the quota.
In December 2014, Flanagan was named as having the second worst voting record among Irish MEPs at the European Parliament, as determined by VoteWatch Europe and reported in Ireland. He explained that this was as a result of his wife being ill and his children needing him.