Protesters, shouting "Allahu Akbar (God is great)", delivered a letter to diplomatic staff at the embassies demanding an apology for the insult caused by the drawings.
Salih Begovic, who identified himself as a member of the protest organising committee, said that a letter had been sent to the Organisation of the Islamic Conference to demand that the United Nations General Assembly condemn Denmark and impose a ban on acts disparaging religious symbols.
The flags of Norway, Denmark and Croatia were burned outside the Norwegian embassy. The protests ended early in the afternoon without major incidents.
Sarajevo police spokesman Jusuf Zornic told reporters that the person who set the flags on fire had been identified, and announced legal action.
The Croatian flag was targeted because the Nacional weekly reprinted the cartoons in its latest issue. The Croatian weekly, otherwise on regular sale in Bosnia-Herzegovina, could not be found at newsagents in Sarajevo on Wednesday, and newspaper distributors had no official explanation.
The Islamic Community of Bosnia-Herzegovina did not support the protests.