I was in India this February, making a radio documentary on Bollywood: the pulse of India, its political barometer, its social messenger. The films are never just entertainment. They embody national aspirations and values, glue people together, foster ideals, show up fissures and faults, uplift the masses or dishearten them, communicating the state of the nation.

The long, singing, dancing – sometimes melodramatic –on-screen sagas are both escapist yet meaningful. They define what it means to be Indian more eloquently than any politician, media reporter or novelist can.

The programme broadcast on the BBC World Service was an exploration of how Bollywood affects and reflects India today. In particular we were interested in the top male stars: Shahrukh Khan, Aamir Khan and Salman Khan, all of Muslim heritage. The three kings dominate the Mumbai cinema scene at a time of Hindu nationalist resurgence and Islamicist terrorism.

Interestingly, female Muslim artistes are less prominent. Once they shone brightly in the firmament of the great stars. I blame the new, puritanical Islam, which is gaining influence in India as well as elsewhere in the world.

India is a vast, multi-religious, multi-ethnic nation that was governed by the secular Congress Party until the mid-nineties. The BJP, a right wing Hindu nationalist party, emerged in 1996 and won an outright majority in parliament in 2014. Prime Minister Narendra Modi is a divisive figure. When he was chief minister of the Gujarat in 2002, around 2,000 Muslims were killed while many others were attacked, raped or otherwise driven out. A smaller number of Hindus were killed by Muslims. He is hugely popular among ardent Hindus, as well as the business sector due to his neo-liberal economic policies.

The programme took us on a fascinating journey. My producer is a Hindu, I a Muslim. We thought we knew this country. The great writer EM Forster rightly observed: "Nothing is identifiable in India. The mere asking of a question causes it to disappear or merge into something else." We came away more aware and wary of easy generalisations.

You can learn the history of modern India through its films, the first of which came out in 1913. By 1930, Mumbai was churning out 200 films per year. The stories were anti-colonialist, anti-communalist and anti-caste. They covered the wars with Pakistan and China, corruption, moralism and hypocrisy, western arrogance, the treatment of females. The British, and later Indian, governments tried to censor them. One day, when I was little and with my mum, the police came into the cinema in Kampala and told us to leave. The film Shree 420, was deemed to be anti-British. (Lest people don't know, there was no freedom of expression under colonialism).

The three kings dominate the Mumbai cinema scene at a time of Hindu nationalist resurgence and of course, Islamicist terrorism

Bit by bit, Hindi movies have pushed boundaries. More importantly, directors, actors and producers maintained artistic integrity and inclusivity. A Muslim Indian friend – a playwright and screenwriter – once told me off the record: "Whatever these bastards in politics do – the ethnic poison they leak out – we will always tell stories to subvert them. For us religion, colour, class does not matter. Muslims have been there from the very beginning – actors, actresses, songwriters, directors. People love us. That is our power. Our quiet and continuing revolution. Hindu fanatics hate these Khans. But they can't touch the superstars." He is right. Up to a point. Shahrukh is a like a God; Salman is the nation's fave bad boy and Aamir's last film, Dangal, was the most profitable film ever made in Mumbai. They have more fans than any Bollywood celeb. Not bad for men in their early fifties.

However, we found, that the higher they rise, the more elusive and cautious they are becoming. If they ever assert their Muslimness or talk publicly about rising anti-Muslim discrimination, a deafening roar and social media odium erupt, even though Shahrukh and Aamir are married to non-Muslim women – Gauri and Kiran, respectively – and Salman's mother, Sushila, is a Hindu.

Two years back Aamir – who is also a committed social reformer – said on Indian TV that rising intolerance in India had made him and his wife, filmmaker Kiran Rao, fear for their futures. He was accused of "treachery" by far-right groups, of a "moral offence" by the ruling BJP party. While many actors defended him, some joined in the chorus of denunciation. He was forced to explain his views. More recently Shahrukh had to placate extreme Hindu nationalists who objected to a Pakistani actress starring in Raees, his last film. Alarmingly, these stars are decried by Muslim fundamentalists, for whom Bollywood is a factory of sin.

Most insiders we talked to were still optimistic, still upbeat about Bollywood's resilience and openness. I do hope the forces of darkness do not snuff out that light. But in our times, it would be naïve to assume it could never happen.

Yasmin Alibhai-Brown is a journalist, columnist, broadcaster and author.