Nine people, including a Canadian woman, have been killed, and at least 29 injured in a shootout between gunmen and police, Jordanian security sources have said.

Three other civilians and five police officers were also among the nine killed at the castle in Karak, in south Jordan, on Sunday.

Some of the 29 people taken to hospital are said to have serious injuries.

Jordanian security forces freed tourists who, who had been trapped inside the medieval castle, after storming the building where armed men had taken shelter following the shoot-out.

Police said gunmen shot at officers patrolling the city before entering a Crusader-era castle perched on top of a hill.

Prime Minister Hani al Mulki told parliament "a number of security personnel" had been killed and that security forces were laying siege to the castle.

The identity of the assailants was not immediately clear, but a former government minister from Karak city, Sameeh Maaytah, said there were signs Islamist militants may have been behind the attack.

"This was a group that was plotting certain operations inside Jordan," Maaytah told pan-Arab news channel al-Hadath