A federal judge has ordered New York state's Democratic primaries to be reinstated on June 23 after former presidential candidate Andrew Yang and others sued the state for canceling the election due to the coronavirus.

Judge Analisa Torres of the Southern District of New York said Tuesday that the decision by the New York State Board of Elections (BOE) to cancel the primary was unconstitutional.

The resolution that removed Yang and nine others -- including Sen. Bernie Sanders, I-Vt. -- “deprived them of associational rights under the First and Fourteenth Amendments to the Constitution,” Torres wrote in her decision, ordering that the candidates' names also be reinstated on the ballot.

NEW YORK CANCELS PRESIDENTIAL PRIMARY, CITING CORONAVIRUS, AFTER SANDERS CAMP ASKED TO STAY ON BALLOT

The BOE had cited safety concerns as the reason to cancel the election, referring to an amendment signed by Gov. Andrew Cuomo on April 3 that authorized the state election board to “omit…from the ballot” any candidate who “announces that they are terminating or suspending their campaign."

This ruling removed 10 presidential candidates from the ballot, including Sanders and Yang, leaving Joe Biden as the sole candidate.

Both Sanders and Yang had announced they were dropping out of the race prior to the ruling.

SANDERS URGES DNC TO STRIP NY OF ITS DELEGATES AFTER SCRAPPING PRESIDENTIAL PRIMARY

But Yang claimed this ruling was unconstitutional because he “believed and expected that [his] name would nonetheless stay on the ballot in states with upcoming elections,” and he “hope[d] that voters would express their preferences by voting in the upcoming elections.”

Yang on Tuesday tweeted about the results, releasing a statement saying: "I'm glad that a federal judge agreed that depriving millions of New Yorkers of their right to vote was wrong. I hope that the New York Board of Elections takes from this ruling a newfound appreciation of their role in safeguarding our democracy."

Torres ruled that “If all but one of the presidential candidates are removed from the ballot and the primary is not held, Delegate Plaintiffs will be deprived of the opportunity to compete for delegate slots and shape the course of events at the [Democratic National] Convention, and voters will lose the chance to express their support for delegates who share their view.”

The judge also said there is enough time for the state of New York to figure out how to implement safe voting measures before the June primary amid the coronavirus outbreak.

“Protecting the public from the spread of COVID-19 is an important state interest. But the Court is not convinced that canceling the presidential primary would meaningfully advance that interest,” Torres added.

The BOE voted to cancel the presidential primary elections, but all state-level elections -- including congressional elections -- were not canceled due to health concerns.

CLICK HERE FOR THE FOX NEWS APP

“Finally, though all states are impacted by the current public health crisis, and some have rescheduled their presidential primary elections in light of COVID-19, New York is the only one to have canceled its primary, casting further doubt on Defendants’ contention that scrapping the primary is necessary to combat the risk posed by the virus,” Torres added.