Three were burned badly enough to be hospitalised.
Once rare, self-immolation became a tactic of protest in the Middle East and North Africa ever since a vegetable seller in Tunisia set himself on fire in December 2010 to protest police harassment, setting off an uprising that toppled the government and sparked similar movements elsewhere in the region.
The Moroccans were part of the "unemployed graduates" movement, a loose collections of associations across the country filled with millions of university graduates demanding jobs. The demonstrations are often violently dispersed by police and in some towns and cities have resulted in sustained clashes.
While the official unemployment rate is only 9.1 per cent nationally, it rises to around 16 per cent for graduates.
On Thursday, the government elected in November presented its new plan to parliament with a focus on job creation, education and improving health care. The Islamist-led government promised to create 200,000 new jobs a year through public and private investment.
Around 160 members of the movement have been occupying an administrative building of the Ministry of Higher Education for the past two weeks in Rabat as part of their protest. Supporters would bring them food until two days ago when security forces stopped them.
"The authorities prevented them from receiving food and water, so five people went outside to get food and threatened to set themselves on fire if they were stopped," said Youssef al-Rissouni of the Moroccan Association for Human Rights.
Of the three who were hospitalised, two were in serious condition, while the other two just had their clothing singed, he added.
A video published by the group online shows a crowd tossing bread over the heads of police towards a building. Several young men on the building then douse themselves with a liquid and jump down and begin collecting the bread.
When riot police armed with truncheons move to stop them, at least two of the men burst into flames and begin running around wildly before they are surrounded by supporters and the flames apparently smothered.
Photos afterwards showed men with large sections of their skin burned.
The online newspaper Goud reported that two of the men had second degree burns and were going to be sent to the Casablanca burns unit.
While the Moroccan economy has posted steady growth rates for the last several years of around 4 to 5 per cent, it has been unable to create enough jobs for the growing numbers of young people entering the work force every year.