At least 10 people have been killed and several others were taken hostage by fighters who have holed themselves up in a medieval castle in the Jordanian city of Karak, according to officials.
A standoff between Jordanian special forces and fighters inside the castle continued after nightfall on Sunday, several hours after the first shooting.
Government officials declined to comment on local news reports saying the attackers were holding hostages.
Police in the mountainous city, around 120km south of the capital Amman, freed 10 people, including foreign tourists, but some were reportedly still being held in the Crusader-era castle.
Hani al-Mulki, Jordan's prime minister, told parliament "a number of security personnel" had been killed and that security forces were laying siege to the castle.
There was no immediate claim of responsibility for the attack.
Mohamed al-Momani, a government spokesperson, told Jordanian media that seven policemen, a Canadian tourist and two civilians were killed in the shootings. At least 27 others were reported wounded.
The Canadian government confirmed the death of one of its nationals.
Reports of house fire
Police said the violence began when fighters starting shooting at officers patrolling the town, then entered the castle, perched on top of a hill.
A police patrol had received reports of a house fire in the town of Qatraneh in Karak district, a statement by Jordan's Public Security Directorate said.
Officers responding to the call came under fire from inside the house, the statement said, adding that two policemen were wounded, while the assailants fled in a car.
In another attack, the Public Security Directorate said, fighters fired on a security patrol in Karak, causing no injuries.
At the same time, armed men holed up in the Crusader castle opened fire on Karak police station, "wounding several policemen and passers-by" who were rushed to hospital, according to the statement.
"Police and security forces have surrounded the castle and its vicinity and launched an operation to hunt down the gunmen."
The Public Security Directorate said the hunt for "the five or six gunmen" thought to be involved in the shootings was under way.
Witnesses posted purported amateur videos and images of the incidents on social media.
Several incidents over the past year have jolted the Arab kingdom.
Jordan is a leading member of the US-led coalition battling the Islamic State of Iraq and the Levant (ISIL) group in neighbouring Iraq and Syria.
It has carried out air strikes targeting ISIL fighters and hosts coalition troops on its territory.
Moaz al-Kassasbeh, a Jordanian fighter pilot, was captured by ISIL, also known as ISIS, when his plane went down in Syria in December 2014 and he was later burned alive in a cage.
Karak is Kassasbeh's hometown.
In June, a suicide bombing claimed by ISIL killed seven border guards near the Syrian frontier.
According to sources close to ISIL, almost 4,000 Jordanians have joined armed groups in Iraq and Syria, where an estimated 420 have been killed since 2011.
Source: Al Jazeera and news agencies