Thousands of frustrated visa lottery winners sued the U.S. government. They won.

Nearly 10,000 winners of the FY 2020 Diversity Visa Program, better known as the visa lottery, who were frustrated by their failure to obtain consular interviews to process their U.S. immigrant visas on time, won a court battle this week.

The U.S. District Court for the District of Columbia ruled on Wednesday that the U.S. Department of State, which administers the immigration program, must process 9,905 visas that were allocated in the DV-2020 lottery.

U.S. District Judge Amit P. Mehta ordered the Department to “commence processing the 9,905 DV-2020 visas as soon as is feasible and to conclude such processing no later than the end of the 2022 Fiscal Year, or September 30, 2022,” according to court documents.

The visa lottery allocates up to 55,000 permanent resident cards, known as green cards, for immigrants with historically low rates of immigration to the U.S. The winners are drawn from random selection by computer from among qualified entries.

The annual program’s guidelines stipulate that all winners, including family members or derivatives, must be issued immigrant visas by Sept. 30 of the program’s fiscal year, which in this case was Sept. 30, 2020.

But chronic delays at American embassies and consulates around the world, stemming in large part from the coronavirus pandemic, among other causes, did not allow the qualified winners to complete the mandatory consular processing for the visa issuance.

In light of these unintended mishaps, diversity visas winners have filed several class-action lawsuits against the Department of State, both under the Trump and Biden administrations.

In a statement released Wednesday, the foreign policy agency said it was aware of the various court orders pertaining not only to the DV-2020 lottery visa, but also to the DV-2021 edition of the program, whose visas many foreigners were also unable to obtain on time.

“We will publish public guidance on this website regarding the Department’s plan for complying with these orders as it becomes available,” officials said.

In the class action lawsuit Gomez v. Biden, the D.C. district court had already instructed in August that the Department was required to process the 9,905 reserved diversity visas in a random order, but it did not established a time frame for processing them.

With this week’s order, the cards are finally laid out, and the visas on the horizon for the lucky winners, who will be able to immigrate to the United States legally and permanently with a green card.

“The court understands that waiting up to another full year will disappoint Gomez class members who hope to secure a reserved DV-2020 visa,” Judge Metha wrote in his court order.

“However, this court must balance the interests of the class with the resource constraints of the State Department, along with the interests of thousands of others who are patiently waiting for their immigrant and nonimmigrant visas to be adjudicated and issued by consular offices,” he concluded.

Daniel Shoer Roth is a journalist covering immigration law who does not offer legal advice or individual assistance to visa lottery applicants. Follow him on Twitter @DanielShoerRoth or Instagram. The contents of this story do not constitute legal advice.