Stuart Rodgers stayed in the toilet for over an hour in order to have the opportunity to heckle the Prime Minister over public sector cuts.
A court heard that the 23-year-old activist burst into the room of the Glasgow hotel where Cameron was addressing hundreds of Conservatives, and shouted: "No ifs, no buts, no public sector cuts."
Rodgers was subsequently tackled and taken away by Special Branch officers, reports The Scotsman.
At Glasgow Sheriff Court, Rodger admitted behaving in a threatening or abusive manner by violating a security cordon, shouting and failing to desist, attempting to approach Cameron and causing fear and alarm.
He was sentenced to 100 hours of community service, reduced from 150 hours because of his guilty plea.
Rodgers had previously been fined £200 for throwing blue paint over deputy Prime Minister Nick Clegg when he visited Glasgow earlier this year.