Image copyright AFP/Getty Image caption Secular activists in Bangladesh hold a torch-lit protest against the killing of Avijit Roy, a US blogger of Bangladeshi origin

The recent killings of atheist bloggers in Bangladesh have raised concerns about freedom of speech and shrinking space for secularist thoughts. But increasingly, Bangladesh appears to be heading down a new and even more dangerous road.

Recent attacks on Shia Muslims and death threats against Christian priests have raised the spectre of sectarian terror, which was unthinkable in this largely Muslim country with a tradition of social harmony.

Thursday's attack on a Shia mosque in Bogra, in the north of the country, left one dead and several wounded. The death toll is small compared to the carnage Shia in Iraq and Pakistan have suffered in recent years.

But it sent shockwaves through Bangladesh - which has secularism enshrined in its constitution.

This is the first time assailants have walked into a mosque in Bangladesh and shot people dead. A line has been crossed.

Image copyright AP Image caption The attack on a Shia mosque sent shockwaves through Bangladesh

''We have never seen in our entire history an incident where people have been killed inside a mosque,'' said retired general AMM Muniruzzaman, President of the Bangladesh Institute of Peace and Security Studies.

The killing comes less than a month after a bomb attack on a traditional mourning procession of Shia at Hoseni Dalan shrine in Dhaka, which left two people dead.

Lived together peacefully

The shrine has hosted the Ashura procession for more than 400 years without incident.

Bangladesh has sheltered itself for years from the kind of sectarianism that has ripped through the social fabric of Pakistan. The Sunni Muslim majority has very little quarrel with the small Shia population.

Children grow up learning Shia folklore as their own. Large number of Sunnis participate in the Shia Ashura procession.

''We have lived in this area for generations and never had any problems with others," Abu Zafar, director of the Shia mosque in rural Bogra, said.

Mr Zafar said although they had become cautious after the Hoseni Dalan attack, they never thought anyone would kill people at prayer inside a mosque.

Image copyright EPA Image caption Security has been beefed up at the mosque in Dhaka since the attack

'Clear pattern'

A more subtle but ominous campaign has also started against the country's tiny Christian population. A number of priests have been sent text messages, threatening them with death.

On Wednesday, the head of a Baptist Church in Rangpur, 60 miles (100km) north of Bogra, received a letter, asking him to have his "last supper".

''We will kill those who spread Christianity one by one… the government of Bangladesh will then understand the presence of Muslims in this country'', the letter sent to Revd Barnabas Hemrom said.

The minister told the BBC the letter was addressed to him but also had names of ten other priests working in the area.

Security analysts see a clear pattern emerging, where the targets are ordinary people from different faith and sects.

''Attacks on Shia and threats against Christians are evidence of efforts to create a sectarian, religious divide in Bangladesh,'' Gen Muniruzzaman said.

Image copyright AFP Image caption The attack on a Shia shrine in October injured at least 80 people

The pattern bears hallmarks of the Islamic State organisation which has already claimed responsibility for the attack on Shia and the killing of two foreigners.

The most recent issue of the militant organisation's magazine hails the spate of attacks as the "revival of jihad in Bengal" and urges its followers to target foreigners, Shia and Christians in Bangladesh.

The magazine claimed various groups in Bangladesh have buried their differences and come together to follow the IS leader, Abu Bakr al-Baghdadi.

Government in denial

This new development will worry the Bangladeshi government. The terror network that has been killing bloggers since 2013 can be broken up, and the killers brought to justice. More than a dozen suspects are already in police custody.

But if sectarian hatred is allowed to take root, then it can take on a life of its own. Any link-up between local extremist groups and IS could also see the pattern of violence becoming even more bloody.

Image copyright Reuters Image caption The government of Prime Minister Sheikh Hasina denies the existence of IS in Bangladesh

The government of Prime Minister Sheikh Hasina continues to deny the existence of IS in Bangladesh, preferring to blame home-grown jihadi groups such as the Jamiatul Mujahideen Bangladesh or JMB for the attacks.

The JMB achieved notoriety in the early years of this century through public lynching of left-wing militants and assassinations of judges.

Eleven years ago they shocked the country by near-simultaneous bomb attacks in all of the country's 64 districts. Its top two leaders were arrested soon afterwards and hanged in 2008.

Since many of the JMB militants are alleged to be former activists of Bangladesh's biggest Islamist party, the Jamaat-e-Islam, the government believes all the attacks are their handiwork, claimed under different names and designed to destabilise Bangladesh.

Nearly all of Jamaat's top leaders have been tried and convicted on charges of crimes against humanity committed during the country's independence war in 1971. Three of those have already been hanged.

Image copyright AFP Image caption Ali Ahsan Mohammad Mujahid (pictured, left) and Salahuddin Quader Chowdhury were executed in November

For three years they tried to force the government to change course through violent and often bloody agitation. They failed, leaving many of their cadres dead in clashes with police.

But the government is yet to win the argument. Jamaat-e-Islam happens to be a key component of the opposition alliance, which the government has been busy trying to dismantle.

As a result, the government's denial of IS's presence in Bangladesh and claims of Jamaat links to the killings are often greeted with scepticism.

However, the apparent launch of a sectarian terror campaign against Shia and Christians may force the government to take the IS claims seriously.

Analysts believe an urgent crack down on the re-emerging militants is necessary to protect vulnerable minority communities as well as the secular character of the Bangladeshi state.