DHAKA (Reuters) - Before Tamim Ahmed Chowdhury orchestrated Bangladesh’s worst militant attack, he sought and won approval for it from Islamic State.

Policemen sneak a look inside the Holey Artisan Bakery and the O'Kitchen Restaurant as others inspect the site after gunmen attacked, in Dhaka, Bangladesh, July 3, 2016. REUTERS/Adnan Abidi/File Photo

A Canadian of Bangladeshi origin, he was told by his contact in the militant group, Abu Terek Mohammad Tajuddin Kausar, to target foreigners, according to a senior police official who has seen communications between the two men.

Chowdhury, located in Bangladesh at the time, proposed an attack on a Dhaka eatery frequented by expatriates.

On July 1, a group of gunmen stormed the Holey Artisan café in the city’s Gulshan neighborhood, murdering 22 people, most of them foreigners, in an overnight siege that shocked the country.

The back-and-forth between Chowdhury, 30, and Kausar, 35, which includes drafts of articles later published in Islamic State magazines, has not been previously reported.

Together with attempts by people linked to Islamic State to recruit and fund militancy in the country, the documents show the extremist organization has built deeper connections with Bangladeshi militants than was previously known.

The police official declined to be named due to the sensitivity of the information. Reuters could not independently verify the contents of the communications.

As Islamic State comes under pressure in its home base of Syria and Iraq, its activities in outposts such as Bangladesh could intensify, experts have said.

The extent of Islamic State’s influence in Bangladesh will be key to the country’s garment sector that employs millions of people and earns $28 billion a year in exports.

Any sign the global jihadi network is making inroads could force Western brands to look elsewhere for cheap clothes.

In the year before the cafe atrocity, a string of grisly individual murders, including of bloggers and foreigners, had already raised the alarm for overseas investors.

In its Rumiyah magazine published after the café massacre, Islamic State claimed two dozen attacks in the country since September 2015. The claim could not be independently verified.

LOCAL MILITANTS OR ISLAMIC STATE?

After the siege, police raided suspected jihadi hideouts and said they killed dozens of militants and arrested hundreds more.

Still, the government of Prime Minister Sheikh Hasina has said Islamic State does not exist in the impoverished South Asian nation of 160 million people, and instead blames the rise in political violence on the Islamist opposition.

Opposition leaders deny any link and say it can be traced to the bitter rivalry, which has long poisoned politics in the country, between Hasina’s ruling Awami League and its main rival, the Bangladesh Nationalist Party (BNP), as well as Jamaat-e-Islami.

“These are all home-grown people,” said Interior Minister Asaduzzaman Khan, adding that the siege militants belonged to a new faction of Jamaat-ul-Mujahideen Bangladesh (JMB), a banned group he said had ties to the opposition Jamaat-e-Islami party.

An aide to Hasina said that, while local militant groups had links with Islamic State, the extent of support was limited.

“They are not an organized group here. People with Islamic State links are here. But that is not to say Islamic State is here.”

FUNDING AND RECRUITING

Bangladesh police first came to know about Chowdhury around fall of last year, but they did not know his whereabouts, the police official said.

In December, Dhaka police seized about 3.9 million taka ($50,000) destined for a close associate of Chowdhury’s.

The money, which the police official said was sent via the informal hawala cash transfer network, came from a UK-based company. The company’s founder, Siful Sujan, was killed a few days later in Syria.

At the time, investigators could not establish the money had been sent on Islamic State’s instructions, the police official said.

Chowdhury’s group, meanwhile, was recruiting.

Tanvir Kaderi and his wife, Abedatul Fatema, had a comfortable middle-class life in Dhaka, with two children and steady jobs.

“We were a very happy family,” Kaderi’s son Mohammed Tahrim Kaderi Abir wrote in a confession presented before a magistrate.

Abir, an eighth grade student, wrote that his parents’ behavior started to change after they went on the Haj pilgrimage in 2014.

After that, Kaderi told a preacher he had dreamed he was standing with a weapon in his hand in the middle of a desert.

Kaderi also started spending time with acquaintances from the local mosque, who introduced the family to others, including associates of Chowdhury.

They in turn preached to the family about faith and jihad and showed them videos of the war in Syria. One gave them a copy of Dabiq magazine, an Islamic State publication, according to the confession.

The preparations for the café attack began at least as early as June, around the beginning of the Muslim holy month of Ramadan, according to Abir’s confession. Kaderi rented an apartment in Basundhara area of Dhaka, near the cafe.

A few days later the five militants who conducted the attack showed up at the house. Kaderi’s family moved to Dhaka’s old city the night of the raid.

MAGAZINE INTERVIEWS

Chowdhury was killed on Aug. 27. That and the other raids gave police access to his correspondence with Kausar.

In one, Chowdhury was asked by Kausar to answer questions for an interview, which was eventually published in Dabiq in April under the nom de guerre Abu Ibrahim al-Hanif.

Al-Hanif was identified in the magazine as head of Islamic State in Bangladesh.

In another, Chowdhury sent the draft of an article about the café attack, which was published after his death in Rumiyah magazine, the police official said.

Kausar’s mother said he moved to Australia in 2006 and she had not heard from him since before the attack. Tahera Begum, who lives in a town 135 miles from Dhaka, said she did not know whether he had links with Islamic State.

Before his death, Chowdhury made Kaderi the new point of contact with Kausar, the police official said.

At around 7.30 p.m. on Sept. 10, police knocked on the door of Kaderi’s apartment, where his wife, one of his sons and some associates were hiding.

In the ensuing chaos, police were attacked with grenades and knives, while some women in the apartment threw chili powder at them. Kaderi ran into a room.

As they tried to apprehend him, he swung a scythe at police, who were using his son as a shield.

Kaderi told his son, “If you get hit, you will either be martyred or Allah will reward you.”

By the time the raid was over, Kaderi had slit his own throat. The last known link to Islamic State in Bangladesh was dead, although the police official said they did not know if anyone else was in contact with the militant group.

POLITICAL STRIFE

Opposition leaders accuse the government of using militancy as an excuse to stifle dissent.

“A democracy deficit is definitely encouraging the extremists,” said Mirza Fakhrul Islam Alamgir, BNP’s secretary general who spent months in jail and now faces prosecution in dozens of cases.

The Jamaat leadership has gone into hiding after several of its top leaders were executed during the past two years for war crimes committed during the country’s 1971 war of independence from Pakistan.

In an email, Maqbul Ahmad, the head of the party, denied any connections with JMB or other militants.

“The government is consistently denying the actual presence of terrorism in Bangladesh,” Ahmad wrote. “Rather they are using it as an effective instrument of repression of Islamists.”

Soon after the café attack, the government placed a bounty of 2 million taka ($25,000) on Chowdhury’s head. A series of raids on militant hideouts followed. By Oct. 3 police said they had killed 42 militants and arrested at least 221 people, according to an internal police report.

Militant groups, including a faction ideologically linked to al Qaeda, have gone quiet and police say the overall security situation is under control, although the threat is not over.