A man who interrupted a speech by David Cameron in a protest over public sector spending cuts has been ordered to carry out 100 hours of community service.

Stewart Rodger, 23, hid in a toilet at the Grand Central Hotel in Glasgow in July to gain access to the room where Mr Cameron was later to address hundreds of Conservatives.

A court heard today that after avoiding security at the hotel, Mr Rodger burst into the room and shouted: “No ifs, no buts, no public sector cuts.”

The 23-year-old was tackled by aides to the prime minister before being led away by police.

He was given a community payback order at Glasgow Sheriff Court today, with the condition that he carry out 100 hours of community service.

The sentence was reduced from 150 hours of community service after the political activist admitted behaving in a threatening or abusive manner by violating a security cordon, shouting and failing to desist, attempting to approach Mr Cameron and causing fear and alarm.

Mr Rodger’s defence lawyer had argued that the security cordon in place at the four-star hotel had consisted of someone asking if he had a pass, and stressed that he had made it only a few yards into the room.

In August last year Mr Rodger, a former Liberal Democrat supporter, was fined £200 at a Glasgow court for throwing an egg containing blue paint at the Deputy Prime Minister, Nick Clegg, in a protest at his party’s coalition partnership with the Conservatives.

The former politics student at Glasgow university said he had not intended to hit Mr Clegg, but that the Lib Dem leader had “deserved it”.

His lawyer at the time, Clare Ryan, told the court that Mr Rodger was “not likely to behave like this again”.

Mr Rodger’s sentencing yesterday came a day after the Mayor of London, Boris Johnson, was heckled on a visit to Bristol.

A number of protesters shouted that the Conservative politician was “not welcome” in the city.