A United States federal court in New York on Wednesday dismissed a lawsuit brought against Prime Minister Narendra Modi by a rights group in connection with the 2002 riots in Gujarat, saying he enjoys immunity as the sitting head of a foreign government.