A judge in the US has thrown out a lawsuit against Indian Prime Minister Narendra Modi, which alleged that Mr Modi had failed to stop anti-Muslim riots in Gujarat in 2002.

The lawsuit was filed in September by a small human rights group called the American Justice Centre (AJC) ahead of Mr Modi’s high-profile visit to the United States.

The AJC admitted at the time that the suit had little chance of succeeding but was meant as a symbolic gesture to raise awareness about what it called Mr Modi’s “inaction” during the riots which left more than 1000 Muslims dead in reprisal attacks after a train carrying Hindu pilgrims was set on fire.

The lawsuit made headlines around the world.

However, US District Judge Analisa Torres upheld the US Department of State’s determination that Mr Modi, as a sitting head of government, is entitled to immunity from civil lawsuits filed in U.S. courts.

A spokesman for Mr Modi’s Bharatiya Janata Party (BJP), told Reuters that the lawsuit was a “frivolous attempt to discredit Modi” and “deserved to be treated with contempt”.

The judge’s decision comes ahead of a planned visit by President Barack Obama to attend India’s Jan. 26 Republic Day celebrations at Modi’s invitation.

Joseph Whittington, president of the AJC and a local politician from Harvey, Illinois, has said that some of his constituents were refugees from the Gujarat violence and he was acting on their behalf.