Twenty foreigners were killed by armed militants in an overnight siege on an upscale Dhaka cafe, the Bangladeshi government said on Saturday.
The militants launched an assault on the Holey Artisan Bakery on Friday, starting a 12-hour stand-off, which ended after Bangladeshi special forces stormed the cafe early on Saturday to free the hostages.
Six gunmen were killed and a seventh was captured and two police officers also lost their lives in the attack claimed by DAESH.
But Bangladesh's Interior Minister Asaduzzaman Khan said on Sunday that the seven gunmen were "home grown" and had no links with international organisations. They were directed by local groups, he was quoted as saying by Reuters.
The security forces managed to rescue 13 hostages.
"All 20 of the hostages who were killed were foreigners," Lieutenant Shahab Uddin told AFP.
"Most of them were Italian or Japanese," he added.
Later, Reuters reported that at least nine Italians, seven Japanese and a US citizen were among the dead.
An Indian teenager was also killed in the attack, the country's foreign minister, Sushma Swaraj, said.
According to an army spokesman, most of the victims had been "hacked to death with sharp weapons."
Tuhin Mohammad Masud, a commander of the elite Rapid Action Battalion, which led the operation, said the cafe itself had been cleared but added that some of the hostage-takers might still be at large.
In a televised address to the nation, Bangladesh Prime Minister Sheikh Hasina urged her countrymen to "resist these terrorists."
"My government is determined to root out terrorism and militancy from Bangladesh," she added.
The attack on the Holey Artisan Bakery, located in the Gulshan District, which is home to diplomats and expats, follows a series of killings targeting religious minorities and foreigners in Bangladesh.
Earlier on Friday, a Hindu temple worker was hacked to death in western Bangladesh and a Hindu priest was stabbed and critically wounded early on Saturday in the southwest of the country.
The government and police blamed homegrown militants for the killings, which they say are part of a plot to destabilise the country.
But the assault on the bakery is unprecedented in terms of the manner it was carried out.
According to Agence France Presse, survivors recounted how the attackers separated locals from the foreigners who were eating side-by-side before embarking on a "killing spree."
"They [the foreigners] were taken to the upper floor and the Bangladeshis were kept around a table," Rezaul Karim, the father of one of the survivors told AFP.
An Argentine chef, who also managed to escape the attack, said the militants were armed with automatic weapons and bombs
"It was a horrendous night," said Diego Rossini, who managed to escape through a terrace during the siege.
"They [the hostage-takers] had automatic weapons and bombs," he said on Argentinian TV as he described how he eventually managed to escape into the next-door building despite coming under fire.
It is not yet clear what broader impact the rampage will have on life and business in the South Asian nation that depends heavily on a $26 billion garment export sector.
The World Bank had warned previously that militancy could derail Bangladesh's path to becoming a middle-income country.
Last month authorities launched a nationwide crackdown on local militant groups, arresting more than 11,000 people, under pressure to act on the spate of killings.