A New York judge ruled this morning that DraftKings and FanDuel must cease operating ahead of a trial that's expected to come next year.

The two companies are currently embroiled in a legal battle with New York Attorney General Eric Schneiderman over whether they are operating illegal gambling sites in the state. Last month Schneiderman sent cease and desist letters to the two companies, demanding they stop operating. While FanDuel has stopped accepting bets in New York, DraftKings has continued to operate.

Justice Manuel Mendez today granted Schneiderman's request for a preliminary injunction that bars the companies from accepting bets. "The protection of the general public outweighs any potential loss of business," Mendez ruled, particularly those with gambling addictions.

For the attorney general's office, this is the first step towards shutting down the sites. "We are pleased with the decision, consistent with our view that DraftKings and FanDuel are operating illegal gambling operations in clear violation of New York law," Schneiderman said in a statement today. "I have said from the beginning that my job is to enforce the law, and that is what happened today."

The key issue the court must decide is whether daily fantasy sports depend on skill or are just games of chance. Schneiderman argues daily fantasy sports companies are operating illegally in New York because the games are ultimately based on luck. The companies have argued that not only do the games require skill, but in fact require more skill than seasonal fantasy sports games, which are already permitted in the state.

Both DraftKings and FanDuel say they'll appeal the preliminary injunction. “We are disappointed with the Court’s decision, and will immediately file an emergency notice of appeal in order to preserve the status quo," David Boies, DraftKings' attorney, said in a statement. "Daily fantasy sports contests have been played legally by New Yorkers for the past seven years and we believe this status quo should be maintained while the litigation plays out.”

FanDuel added that it remains committed to bringing daily fantasy to New York. "New Yorkers have been able to legally play our games for more than six years, and today's preliminary decision was wrong and we expect we will ultimately be successful," a FanDuel spokeswomen said.

But the judge's ruling today may signal an uphill battle for these billion-dollar upstarts, a battle whose outcome could have an impact beyond New York's borders. If DraftKings and FanDuel are found illegal in the state, it could smooth the way for future litigation in states with similar statutes, including Alaska and New Jersey. These unicorns, it seems, are not quite elusive enough when it comes to the law.

UPDATE (December 11, 2015, 4:30 PM ET):

The New York State Court of Appeals granted an immediate stay of the preliminary injunction this afternoon. DraftKings says it will remain fully operational at this time in New York.

"We look forward to a full and fair hearing and are confident we will demonstrate clearly to the Court why we should be able to continue to offer our [daily fantasy sports] games in New York permanently,” Boies, DraftKings’ attorney, said in a statement.