A suspected radical Islamist opened fire on the US embassy in Sarajevo, wounding a police guard in what a Bosnian leader condemned as a "senseless terrorist attack".

Bosnia's intelligence chief Almir Dzuvo said the suspect was Mevlid Jasarevic, 23, a Serbian national with ties to the local Wahhabi community, a radical branch of Islam.

"He crossed the border (between Bosnia and Serbia this morning," he said.

The head of Serbian police Milorad Veljovic said officers were searching the suspect's residence in the southern Serbian city of Novi Pazar, home to a large Muslim community.

Local television showed video footage of a bearded man carrying a Kalashnikov rifle.

A special police unit shot and wounded the suspect before arresting him, police spokesman Irfan Nefic told national BHT television.

"The person who fired an automatic weapon was wounded and arrested during the police operation," he said.

"After receiving medical treatment on the scene the person was hospitalised."

A statement from the US embassy in the Bosnian capital, which closed after the incident, confirmed that the building "had been attacked with an automatic weapon" and had been hit "several times".

A statement posted on the embassy's website said that as well as the main suspect, police had arrested other possible accomplices.

It urged US citizens to "use caution, watch for any suspicious or unusual activity and remain aware of their surroundings."

US State Department spokeswoman Victoria Nuland welcomed the prompt reaction of the Bosnian police.

Bosnian politicians were quick to denounce the attack.

"I firmly condemn the terrorist attack on the US embassy in Bosnia-Hercegovina," Bakir Izetbegovic, the Muslim member of Bosnia's three-man presidency said in a statement.

Following the attack, Bosnia's acting president Zeljko Komsic met US ambassador Patrick Moon.

He told him that Bosnia was capable of "guaranteeing the security of all US citizens and diplomatic representatives" in the country.

"Our country is not a haven for terrorists," he stressed, as the presidency said it had called a special meeting of all Bosnian police branches.

"I expect the competent authorities to carry out a quick and efficient investigation of this senseless act," he added.

Witnesses described scenes of panic as the gunman opened fire.

"I was waiting for a tram when I saw right next to me this guy armed with a rifle firing at the embassy," Igor Parac told AFP.

"People started running in all directions."

Another eyewitness, Admir Hrenovica, told BHR1 television the gun shots had lasted around 15 minutes.

"I first heard several bursts of gunfire and then single shots. People close to me threw themselves on the ground. It was total panic," he said.

Serbian broadcaster B92 reported that Serbian police had stepped up security around the US embassy in Belgrade following the Sarajevo incident.

Serbian police said the suspected gunman had been arrested in Serbia last year when police found him carrying a knife during a visit by Mary Warlick, US ambassador to Serbia, to the Sandzak region on the border between Serbia and Montenegro, which has an important Muslim community.

Bosnia is home to a small minority of followers of Wahhabism, a strict and ultra-conservative branch of Islam which is dominant in Saudi Arabia.

During Bosnia's 1992-1995 war between its Croat, Muslim and Serb communities, a large number of volunteers from Muslim nations flocked to the Balkan country to take up arms.

Many of these Muslim fighters stayed on after the conflict ended and obtained Bosnian citizenship. Some in the mostly moderate Bosnian Muslim community have converted to this more radical branch of Islam.

The local security forces have been cracking down on the Wahhabis. In the summer of 2010 suspected radical Islamists attacked a police station in central Bosnia killing one officer.