Image copyright EPA

Indonesia is the world's most populous Muslim nation, but are its local Islamic traditions in danger of being overtaken by fundamentalism?

As I thread my way through crowds of worshippers at central Jakarta's grand Istiqlal Mosque, traditionally dressed religious students grab my arms and pull me towards them.

"Take your photo with me!" shouts one. "No, first with me!" shouts another. Several small cameras appear as I am propelled to the centre of their smiling, boisterous group. All raise their thumbs in the air as the cameras start clicking.

I have visited many mosques around the world and I cannot remember ever getting such a warm and friendly reception. Though when I relate this experience to Yenny Wahid, founder of a Jakarta-based research centre on religion and daughter of the late Indonesian President Abdurrahman Wahid, she is not surprised.

This, she says, is an example of a particularly Indonesian approach to Islam, known as Archipelago Islam.

Image copyright Getty Images

"It really puts an emphasis on moderation, on tolerance, on protecting minority rights and basically has a big emphasis on a life of harmony," she says. "So, it's not strange when you see a woman in a headscarf walking hand in hand with a nun here."

Archipelago Islam, or Islam Nusantara as it's known locally, was built over the centuries on Islam that arrived from several other parts of the world and was initially intertwined with Hinduism and ancient Javanese religions. In a large and diverse country stretching over 3,000 miles from east to west and composed of more than 17,000 islands, a less tolerant and inclusive interpretation of the Muslim faith may have struggled to survive. It came to be based on five principles - social justice; a just and civilised humanity; belief in one God; Indonesian unity; government by the will and consent of the people.

Such values evidently weren't shared by those behind the Bali bombings of 2002 which killed more than 200 people, many of them foreign tourists. But since then the country has been relatively successful in curbing extremism.

Image copyright Getty Images

"We're not just coming up with a counter narrative we coming up with a counter identity, and that's what AI is all about," says Yenny Wahid. "We believe we're good Muslims but to be a good Muslim we don't have to accept the recipes that are handed out by some radicals from the Middle East."

An estimated 500 people in Indonesia have gone to fight for Islamic State in Syria. That sounds a lot until you compare it with the estimated 700 from the UK who are thought to have done the same. Britain is home to less than three million Muslims, while Indonesia, the world's most populous Muslim nation, has 70 times that number.

But times do seem to be changing. When I first came to Indonesia 20 years ago there was little obvious sign of Islam in the streets. Now more men are wearing traditional dress, and women hijabs and headscarves. Sidney Jones, an American woman who has lived in the country for several decades, says public displays of faith and religious conservatism have grown year by year.

"When I first came here they used to have transvestite beauty contests, you couldn't get away with that in a million years now in Indonesia," says Jones. "There's an increasing attempt by some groups to try to enforce morality by the state which is something we haven't seen before in Indonesia."

Driving through bustling central Jakarta the shrieks of a protesting crowd grow louder as my taxi passes the presidential palace. To my left a passionate crowd chanting "God is Great!" wave large black banners demanding the expulsion of an American mining company.

Image caption Hizb ut-Tahrir demonstrators protest against an American mining company

They belong to the hardline group Hizb ut-Tahrir, which campaigns for the creation of a caliphate ruled by Sharia law. Its campaign literature claims that allowing Western firms to extract Indonesian minerals breaches Sharia - and the group's local spokesman, Ismail Yusanto, tells me that 73% of respondents in one recent poll supported the introduction of Sharia, while 81% favoured the country becoming a caliphate.

The country's Minister of Religious Affairs, Lukman Hakim Saifuddin admits that there is growing support for some elements of Sharia law - and says the government is preparing legislation to reflect this.

"We are now considering introducing a ban on drinking alcohol, gambling and prostitution. We will then put these proposals to the people and they will be made law if there is democratic agreement," he says.

The minister insists that moves like this do not signify a drift towards Islamic fundamentalism, but merely reflect the growing sense of pride people here feel for their religion. However, recent actions by a vociferous minority of extremists have led many to question this.

Image copyright EPA Image caption Hizb ut-Tahrir Tahrir protest against a government birth control campaign

In February last year a group of students at an Islamic university on the outskirts of Jakarta declared allegiance to IS. Since then the country has also seen open parades and demonstrations by uniformed IS supporters. But over the past year the country's security services, who've long been working closely with reformed extremists, have been clamping down.

At a court in central Jakarta a young man accused of terrorist offences sits head down as the judge reviews his case. Dressed in a bright orange jumpsuit he's just one of eight men facing similar charges here. None have been charged with membership of so-called Islamic State, raising funds for them or fighting for them in Syria. That is because none of these things are actually illegal in Indonesia, so all are being tried on looser charges of supporting terrorism.

Support for extremist groups like IS, though, is not the biggest worry for human rights groups in Indonesia. What most concerns them are the widespread attacks on religious minorities over recent years as well as the government-backed demolition of many churches, temples and other places of worship.

Elson Lingga, a priest from the northern province of Aceh - the only part of the country currently governed by Sharia law - says Christians are feeling increasingly threatened.

"We are so afraid now that nobody goes to work any more," he told me. "And I even got letters this morning from people in my community suggesting that perhaps it is time for us all to flee the area and become refugees because it's no longer safe for us here."

Image caption Jakarta Cathedral sits opposite the Istiqlal Mosque in central Jakarta

Andreas Harsono of the campaign group, Human Rights Watch, insists that unless incidents like these along with the growing use of draconian blasphemy laws are stopped, this once tolerant nation could well become a failed state.

"Some writers use the word 'Pakistanisation' of Indonesia. Pakistan is a failing state, the amount of violence against minorities in Pakistan is gruesome. Here in Indonesia some people are killed but in Pakistan hundreds die every year," he says.

"Plus we're talking about thousands of blasphemy cases too. Before it is too late Indonesia has to stop this process. If not we are going to have a failing state on the Straits of Malacca and it is going to be a disaster for the world."

Image caption Yenny Wahid with a portrait of her father

Yenny Wahid agrees that such worries, along with the hatred and intolerance spread by Islamic extremists, pose a serious threat.

But she insists that the vast majority of Indonesians here, including the Muslim group, Nahdlatul Ulama which boasts more than 40 million members, support the tolerant principles of Archipelago Islam.

This, Wahid hopes, will help win the battle against groups like IS, not just in her own country, but elsewhere too.

"Archipelago Islam will always be practiced in Indonesia no matter what," she says.

"And I believe we can inspire other Muslims throughout the world to also practice Islam the way it's intended to be, which is as a religion of peace."

Republic of Indonesia Capital: Jakarta Population 261 million

Area 1.9 million sq km (742,308 sq miles)

Major languages Indonesian, 300 regional languages

Major religion Islam

Life expectancy 67 years (men), 71 years (women)

Currency Rupiah GETTY IMAGES

Source: BBC News profile - Indonesia

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.