Interim Mali President Dioncounda Traore has been taken to hospital with a head wound after being attacked by demonstrators, officials say.
He is said to have been unconscious on arrival, but later left the hospital.
The army says it shot dead three people during mass protests by supporters of March's coup who were angry at a deal for Mr Traore, 70, to remain in office for a year.
Mr Traore's initial mandate was due to expire on Monday.
But West African leaders reached a deal with coup leader Capt Amadou Sanogo for Mr Traore to stay on to organise elections and end a northern rebellion.
The deal also saw Capt Sanogo recognised as a former head of state with a salary and a mansion.
Capt Sanogo has been silent all day and has not called on his supporters to leave the streets, correspondents say.
The coup, and ensuing rebel seizure of northern Mali, have led many thousands of people to flee their homes.
Aid agencies say they are extremely concerned about the humanitarian situation in Mali, which is also suffering from the regional drought.
Bamako-based journalist Martin Vogl says soldiers let some of thousands of demonstrators into Mr Traore's office, next to the presidential palace.
"They beat him seriously and tore his clothes," military spokesman Bakary Mariko told Reuters news agency.
One of Mr Traore's close aides told the BBC that the president had suffered minor head injuries. He was later released from hospital.
Reports say he then returned to his residence.
Mr Mariko also said that during the protest "Dioncounda's security shot at people".
"There were three dead and some injured by gunshot amongst the demonstrators," the spokesman added.
Martin Vogl says there is some genuine support for the coup in Bamako and people are unhappy that a representative of the ousted political class was allowed to stay in power for a year.
They want a national convention of Mali's political parties and civic society groups to decide on the interim leader.
The protesters shouted slogans including "Down with Ecowas" and "Down with Dioncounda." Some carried a mock coffin with Mr Traore's name on it.
Earlier, mediators from West African regional bloc Ecowas left Bamako, saying "we have accomplished our mission".
Martin Vogl says that the status of a former head of state gives Capt Sanogo considerable respect, as well as a salary.
Chief Ecowas mediator, Burkina Faso Foreign Minister Djibrill Bassole, also said the coup leader would be able to consult Mr Traore and his prime minister until new elections are held next year.
Last week, Ecowas threatened to reimpose sanctions against the coup leaders, accusing them of continuing to meddle in the country's politics.
Capt Sanogo seized power in March and led the country for less than three weeks, before handing power to Mr Traore, the former speaker of parliament, in the face of intense international pressure and the rapid advance of rebels, whose seized the whole of the north - an area the size of France.
As part of the deal, the government is supposed to focus on recovering the north from a mixture of Tuareg separatists and Islamist fighters.
Some of the groups have links to al-Qaeda's branch in the region, al-Qaeda in the Islamic Maghreb.
Ecowas has said it is preparing to send 3,000 troops to Mali to help the country reclaim its northern territory, but no date has been set for the force to arrive.