DHAKA, Nov. 28 (CGTN) -- A Bangladesh court handed death sentences to seven Islamist extremists for their role in a savage 2016 attack that killed 22 people including 18 foreigners at a Dhaka cafe popular with Westerners.

A special anti-terrorism tribunal delivered the verdict in a crowded courtroom in the capital Dhaka, with judge Mojibur Rahman saying the attackers wanted "to draw the attention of Islamic State (ISIL)" group.

They wanted to "undermine public safety, create anarchy and establish a Jihad(ist)" state, he said, adding that the seven "will be executed by hanging until they are pronounced dead."

"Charges against them were proved beyond any doubt. The court gave them the highest punishment," public prosecutor Golam Sarwar Khan told reporters after the verdict, amid tight security at the court in Dhaka.

One of the eight accused was acquitted, he added.

A defense lawyer said the convicted men would appeal the charges, which include training the attackers and supplying arms, explosives and funds.

The brazen July 1 attack saw five young militants armed with assault rifles and machetes lay siege to the Holey Artisan Bakery cafe in Dhaka's well-heeled Gulshan diplomatic area.

The attack, Bangladesh's worst such incident, shocked the nation of 168 million and unnerved businesses, including the vital garment exports sector, and foreign investors.

Police investigators said the attack was aimed at destabilizing the Muslim majority nation and turning it into an Islamist state.

Nine Italians, seven Japanese, an American and an Indian were among the foreigners to be hacked or shot dead. Two policemen were also killed.

Military commandos stormed the cafe after a 10-hour standoff and freed more than two dozen hostages. The attackers were also killed in the rescue bid.

Eight others - including mastermind Tamim Ahmed Chowdhury, a Canadian of Bangladeshi descent - were killed during raids in Dhaka and its suburbs months after the attack.

The attack fueled tensions over Islamist extremism in the country. The secular government launched a massive crackdown that saw more than 100 Islamist extremists killed and nearly 1,000 others arrested.

Prosecutor Khan said the seven men convicted on Wednesday belong to Jamaat-ul-Mujahideen Bangladesh, a group that seeks to establish sharia rule in the predominantly Muslim country.

Police has blamed the militant group for most of the extremist attacks in the South Asian nation since late 1990s.

"The ruling will set an example. It will give a message to militant groups that none of them will be spared," Law Minister Anisul Huq said.

"We are happy that justice has been served," said Shamsuzzaman Shams, whose policeman brother was killed when he tried to enter the cafe to foil the attackers, adding, "We want immediate execution of the ruling."

However, defense lawyer Delwar Hossain said all seven men convicted on Wednesday will challenge the verdict in a higher court. "They didn't get justice," he said.

The assault was claimed by ISIL but the government has consistently denied the presence of any transnational militant organization, such as Al-Qaeda or ISIL, in the country, blaming domestic militants instead.

The hostage crisis marked an escalation from a spate of murders claimed by ISIL and Al-Qaeda of rights activists, homosexual people, foreigners and religious minorities. It was seen as a major blow to the country's image as a moderate Muslim nation.