(CNN) India 's parliament has passed a bill that would give Indian citizenship to immigrants from three neighboring countries -- but not if they are Muslim.

The controversial Citizenship Amendment Bill (CAB) will fast-track citizenship for religious minorities, including Hindus, Sikhs, Buddhists, Jains, Parsis and Christians, from Afghanistan, Bangladesh and Pakistan.

Opposition parties say the bill is unconstitutional as it bases citizenship on a person's religion and would further marginalize India's 200-million strong Muslim community.

The government, ruled by the Hindu nationalist Bharatiya Janata Party (BJP), said the bill seeks to protect religious minorities who fled persecution in their home countries.

It cleared the Rajya Sabha, India's upper house of parliament where the BJP lacks a clear majority, on Wednesday with 125 votes in favor and 105 against.

The day before, lawmakers approved the bill 311-80 in the lower house of parliament -- the Lok Sabha -- which is dominated by Indian Prime Minister Narendra Modi's BJP.

The bill will now be sent to the President to be signed into law.

"I think it is, without exaggeration, probably the most dangerous piece of legislation that we've had because it amounts to truly destroying the very character of the Indian state and the constitution," Harsh Mander, an Indian human rights activist and author, told CNN.

Mander said the very nature of the Indian constitution is that it is based on secular values.

"Central to the idea was that your religious identity would be irrelevant to your belonging, and it's that which is being turned on its head. It's extremely worrying," he said.

Modi celebrated the bill's passing on Twitter. "A landmark day for India and our nation's ethos of compassion and brotherhood!" he wrote. "This bill will alleviate the suffering of many who faced persecution for years."

The bill's passage has drawn widespread opposition and protests, especially in the northeastern states.

Many indigenous groups there fear that giving citizenship to large numbers of immigrants, who came over the porous border with Bangladesh following independence in 1971, would change the unique ethnic make-up of the region and their way of life, regardless of religion.

Demonstrators shout slogans as they hold placards to protest against the government's Citizenship Amendment Bill in Agartala in India's northeast state of Tripura.

Hindu nationalist agenda

Critics of the bill say it is another example of how Modi and his BJP party have pushed an agenda of Hindu nationalism onto secular India, a country of 1.3 billion people, at the expense of the Muslim population.

The BJP, which was re-elected in May, has its roots in India's Hindu right-wing movement, many followers of which see India as a Hindu nation.

In August, the Indian government stripped the majority-Muslim state of Jammu and Kashmir of its autonomous status, essentially giving New Delhi more control over the region's affairs. That same month, nearly two million people in India's Assam were left off a controversial new National Register of Citizens, which critics feared could be used to justify religious discrimination against Muslims in the state.

And last month, India's top court gave Hindus permission to build a temple on a disputed centuries-old holy site, which holds significance for both Hindus and Muslims. The ruling on the Ayodhya site was seen as a blow to Muslims and came at a time when Muslims increasingly see themselves as second-class citizens.

In 2018, India's Home Minister Amit Shah said Muslim immigrants and asylum seekers from Bangladesh were "termites" and promised to rid the nation of them.

The government maintains the bill is about protecting religious minorities who fled to India to avoid persecution by allowing them to become citizens.

Shah said in a tweet that the bill "will allow India to open its doors to minorities from Pakistan, Bangladesh and Afghanistan who are facing religious persecution."

"It is well known that those minorities who chose to make Pakistan, Bangladesh and Afghanistan their home had to constantly live in the fear of extinction," Shah said. "This amended legislation by Modi government will allow India to extend them dignity and an opportunity to rebuild their lives."

Modi tweeted that the bill, "is in line with India's centuries old ethos of assimilation and belief in humanitarian values."

But critics say India's claims that the citizenship law aims to protect religious minorities "rings hollow" because it excludes Muslim minorities who face persecution in neighboring countries, including the Ahmadiyya from Pakistan, Rohingya from Myanmar, and the Tamil from Sri Lanka.

"The bill uses the language of refuge and sanctuary, but discriminates on religious grounds in violation of international law," said Meenakshi Ganguly, South Asia director at Human Rights Watch, in a statement.

Addressing parliament on Tuesday, Shah said that Muslims "will not benefit from this amendment because they have not been persecuted on the basis of religion."

Speaking to the Rajya Sabha on Wednesday, he added: "Who are you worried about? Should we make the Muslims coming from Pakistan, Bangladesh and Afghanistan citizens of the country? What do you want -- that we give every Muslim coming from any anywhere in the world citizenship? ... The country cannot function this way."