By The Associated Press and NBC News

KARAK, Jordan — Gunmen ambushed Jordanian police in a series of attacks Sunday, including at a Crusader castle popular with tourists, killing seven officers, two local civilians and a woman visiting from Canada, officials said.

At least 27 people were wounded in one of the bloodiest attacks in Jordan in recent memory.

After a long standoff, Jordanian security forces said they had killed the four "terrorist outlaws" behind the attack, which occurred 87 miles south of the capital, Amman.

An official statement did not name the assailants, nor did it say whether they belonged to a militant group. There was no immediate claim of responsibility.

Large quantities of explosives, weapons and suicide belts were seized inside the castle, the statement said.

Government officials declined to comment on local news reports that said the attackers had held hostages who were later freed.

Jordanian anti-terrorism officers prepare to go into a Crusade-era castle Sunday in Karak. Jordan Pix via Getty Images

The shootings were the latest in a series of attacks that have challenged the pro-Western kingdom's claim to be an oasis of calm in a region threatened by Islamic extremists.

The killing of the Canadian tourist could further hurt Jordan's embattled tourism sector, which has declined sharply since the Islamic State group seized large parts of neighboring Syria and Iraq two years ago.

The chain of events began when a police patrol received reports of a house fire in the town of Qatraneh in the Karak district, said a statement by Jordan's Public Security Directorate.

The officers responding to the call came under fire from inside the house, the statement said. Two policemen were wounded and the assailants fled in a car, it said.

In another attack, gunmen fired on a security patrol in Karak, causing no injuries, the statement said.

Armed men also opened fire on a police station in Karak Castle, a Crusader fort, wounding members of the security forces. The statement said five or six gunmen were believed to be holed up inside the castle.

Jordanians gather at the base of the hill where the Karak Medieval castle is located near the town of Karak, Jordan, on Sunday. JAMAL NASRALLAH / EPA

In all, four members of the security forces and a female tourist from Canada were killed in the shootings, though it was not clear if all five were killed at the castle.

Jordan faces homegrown extremism, with hundreds of Jordanians fighting alongside other Islamic State militants in Iraq and Syria and several thousand more supporting the extremist group in the kingdom. Jordan is a key U.S. ally, and a member of a U.S.-led military coalition fighting ISIS.

Over the past year, gunmen have carried out several attacks on members of the Jordanian security forces and foreign trainers. Earlier this year, Jordanian security forces engaged in a deadly shootout with suspected ISIS sympathizers in a northern Jordanian town.

In the most recent incident, three U.S. military members were killed in a shooting outside an air base in southern Jordan in November. The three were in Jordan on a training mission, and came under fire while driving into the base.