The last remaining class-action lawsuit against the United Nations over the cholera epidemic in Haiti was thrown out Thursday by a federal judge, who upheld the organization’s assertion of diplomatic immunity.

In an order filed in Federal District Court in Brooklyn, Judge Sandra L. Townes said the lawsuit, which accused the United Nations of responsibility because the cholera was introduced into Haiti by infected United Nations peacekeepers from Nepal seven years ago, had been dismissed for “lack of subject-matter jurisdiction.”

A little more than a year ago, a federal appeals court in New York dismissed the only other class-action lawsuit seeking redress for Haitians from the United Nations over the cholera epidemic. That ruling also held that the United Nations could not be sued in United States courts.

The dismissal of the Brooklyn case appeared to dash any hope by Haitian victims of the epidemic for financial compensation from the United Nations in an American court judgment.