U.S. District Judge Analisa Torres in Manhattan ruled after hearing arguments a day earlier as lawyers for withdrawn presidential candidates Bernie Sanders and Andrew Yang argued that it was wrong to cancel the primary.
The judge said there was enough time before the primary occurs to figure out how to carry it out safely.
"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 Convention, and voters will lose the chance to express their support for delegates who share their views, the judge wrote. "The loss of these First Amendment rights is a heavy hardship."
She added: "There is also a strong public interest in permitting the presidential primary to proceed with the full roster of qualified candidates."
The Democratic members of the State's Board of Elections voted to cancel the primary even though New York was still planning to hold its congressional and state-level primaries June 23.
They cited the danger to voters from the coronavirus as a reason to cancel the election since former Vice President Joe Biden has been endorsed by the major candidates he had faced.
New York state Democratic party chair Jay Jacobs said: "We are reviewing it."
Jacobs had called holding the primary "unnecessary" with the suspension of Sanders' campaign and said reduced turnout could reduce the need for as many poll workers.
Lawyers who argued before Torres on Monday did not immediately return calls seeking comment.
MORE CORONAVIRUS COVID-19 COVERAGE
COVID-19 Help, Information and Resources
Grieving the lost: Tri-State residents who have died
New York City
Share your coronavirus story with Eyewitness News
Stimulus check scams and other coronavirus hoaxes
Coronavirus prevention: how clean are your hands?
Centers for Disease Control and Prevention on coronavirus
Total count of NYC COVID-19 cases based on patient address