Mali's transition president Diancounda Traore was briefly hospitalised Monday after protesters angry at his appointment in a deal struck with the junta burst into his office and beat him.
A UN envoy said the attack "seriously" endangered diplomatic efforts to resolve Mali's crisis, suggesting that "maybe other options will now have to be considered."
Just hours after mediators left the country pleased at having convinced coup leaders to accept a Traore-led 12-month transition back to democratic rule, thousands took to the streets in protest and overran government offices.
Protesters evaded security and pushed their way into Traore's offices in Koulouba, the headquarters of the general secretariat next to the presidential palace, which has stood looted and empty since a March 22 coup.
"The protesters, who were many, evaded security forces... they found him in his office. He was beaten but his life is not in danger. He was driven to hospital," said a source in the presidency.
Traore was released after undergoing an examination.
"He had a scan which showed no serious injury," said a doctor speaking on condition of anonymity, adding that after leaving the hospital Traore had been driven to a secure location.
Prime Minister Cheick Modibo Diarra appealed for calm, saying the attack was "not worthy of our country."
Speaking on state television, he said: "Mali doesn't deserve this. ... I call on the people, especially the young people, to put an end to (protest) marches."
The incident comes a day after the Economic Community of West African States (ECOWAS) brokered a deal with the junta, prompting relief in the country after weeks of deadlock on the way forward.
"We are all leaving, with the feeling that we have accomplished our mission" set by ECOWAS, Ivory Coast Minister of African Integration Adama Bictogo told AFP earlier on Monday.
Coup leader Captain Amadou Sanogo was threatening to derail the transition back to democratic rule by blackballing recommendations that current interim leader Traore, 70, remain in his position for a 12-month period.
Laborious talks had failed to yield a positive result and Traore was due to step down on Wednesday after a constitutionally mandated 40-day interim presidency, which would have plunged the institutions back into crisis.
But on Sunday Sanogo accepted a sweetened deal as he was offered all the benefits that a former president would be owed: housing, transport, security and an allowance.
Thousands of Malians took to the streets on Monday to protest the transition deal.
"The arrangements made by ECOWAS don't involve Malians. It is a betrayal," said Hamadoun Amion Guindo of the Committee of Malian Patriotic Organisations (COPAM), a pro-coup grouping opposed to Traore.
Some protesters accused Sanogo of "treason" for accepting the arrangement.
One of west Africa's most stable democracies, Mali was plunged into crisis when Sanogo led a band of low-ranking soldiers to oust Amadou Toumani Toure's government.
On April 12 the putschists agreed on a return to civilian rule and Traore was inaugurated as interim leader and formed a government, but the former junta refused ECOWAS proposals that he stay on for a 12-month transition period.
Politicians felt Sanogo had done an about-turn and was jockeying to lead the transition himself.
"We have come a long way, we were a hair's breadth away from an impasse," said Malian journalist and political commentator Tiegoum Boubeye Maiga of the deal.
"On paper the matter is wrapped up. Now it remains to be seen how it will work. I am hopeful. It is important to have given Sanogo the title of former head of state," he added.
In carrying out the coup, the soldiers claimed that the government was incompetent in handling a Tuareg rebellion in the northern desert that began in January.
But the coup only opened the way for the Tuaregs and a motley group of armed Islamists backed by Al-Qaeda in the Islamic Maghreb and criminal bands to seize the northern half of the country, an area larger than France.
Convinced that tensions in Bamako had eased, analysts said leaders could now turn to the north.
"Here you have a country which was on the brink of catastrophe in the south, and suddenly finds itself back on the rails. Now we can focus on northern Mali. The junta did not lose face, and democracy triumphed," political analyst Mamadou Samake told AFP.