A man who murdered two soldiers and wounded three people in what Bosnia's prime minister said was an "attack on the state" blew himself up as police were about to enter his home, authorities have said.
The attacker, armed with an automatic rifle, killed two soldiers in a betting shop then shot at a passing bus. Fragments of the broken glass injured the driver and two passengers.
A witness who did not want to be identified for fear of retribution said the man walked into the shop, separated the two soldiers from others and shot them. He wore a band around his head with some Arabic letters.
The gunman fled to his home nearby and an explosion could be heard before police entered the house.
"The suspect killed himself using an explosive device," said police spokesman Irfan Nefic.
The attack happened in the Sarajevo suburb of Rajlovac, opposite the gate of an army barracks.
Authorities refused to say whether the attack was an act of terrorism before the investigation was over but after an emergency session of his cabinet, Bosnia's prime minister Denis Zvizdic said it was "an attack on the state".
The Bosnian army issued a statement saying two of its soldiers were killed and one - a passenger on the bus - was injured. The security level has been stepped up at military locations throughout the country.
Bosnian Muslims traditionally practise a moderate form of Islam, preached by the country's official Islamic Community, but some have embraced radical teachings from foreign fighters who came to help Muslims during the 1992-95 Bosnian war.
Authorities said that 94 Bosnians have gone to fight in Syria. Their records show 56 of them have returned, while 26 died there.