A U.S. federal court on Wednesday dismissed a lawsuit against Indian Prime Minister Narendra Modi that had accused him of “attempted genocide” for his alleged role in the 2002 riots in the western Indian state of Gujarat, according to media reports. Over 1,500 people, most of them Muslims, were killed in riots that broke out when the state was under Modi's leadership.

The lawsuit had been filed by the American Justice Center, a human rights group, ahead of Modi’s maiden visit to the U.S. in September last year. It alleged that Modi, who then served as the state's chief minister, was responsible for extrajudicial killings, “organized violence, large-scale displacement of members of the Muslim-minority population, and the continuing denial of justice,” according to media reports.  

At the time, Indian officials had dismissed the lawsuit as a distraction, calling it “frivolous and malicious.” 

On Wednesday, New York Judge Analisa Torres dismissed the lawsuit on grounds that Modi, as a sitting head of government, enjoyed “immunity from jurisdiction.”

“In light of the determination by the Executive Branch that Prime Minister Modi is entitled to immunity as the sitting head of a foreign government, he is immune from the jurisdiction of this Court in this suit,” Torres reportedly said.

Modi, who belongs to the right-wing Bharatiya Janata Party (BJP), has consistently denied any role in the violence and India's apex court has also cleared him of all charges. However, the U.S. government, believing that Modi did not do enough to prevent the escalation of violence during the riots, had put him under a visa ban in 2005. The ban was only lifted after Modi was formally invited to visit the U.S. by President Barack Obama following BJP’s landslide victory in the Indian elections in May last year.

The decision by the New York court comes just days before Obama is scheduled to visit India at Modi’s invitation to attend the country’s Republic Day celebrations in the capital city of New Delhi on Jan. 26.