A New York Supreme Court justice on Friday granted a preliminary injunction to Attorney General Eric Schneiderman to stop daily fantasy operators DraftKings and FanDuel from doing business in the state.

Justice Manuel Mendez agreed with Schneiderman's contention that the companies are operating illegal gambling sites based on how New York law defines gambling. Lawyers for DraftKings and FanDuel argued that their clients could not have violated gambling statutes because they were taking in entry fees and not wagers. The main support for their contention was a New Jersey case -- an unpublished decision in Humphrey v. Viacom (2007) -- which Mendez disregarded, saying that what they took in were in fact bets under New York law.

"New York State penal law does not refer to 'wagering' or 'betting,' rather it states that a person, 'risks something of value,'" Mendez wrote. "The payment of an 'entry fee' as high as $10,600 on one or more contests daily could certainly be deemed risking 'something of value.'"

An appeal of the ruling by DraftKings and FanDuel will be heard Friday afternoon, according to the attorney general's office. Unless the judge grants a stay, the sites will be forced to stop accepting play from New York customers.

DraftKings and FanDuel experienced a setback with the New York Supreme Court's ruling. Matthew Emmons/USA TODAY Sports

DraftKings said Mendez "misapplied the law" when filing its appeal.

"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," DraftKings said in a statement.

FanDuel also released a statement after Mendez's ruling: "This is only the beginning of the legal process and, perhaps more importantly, the New York legislature is already moving forward on action to ensure our game remains legal and is regulated, which we strongly support. The court specifically noted that this was not a final determination of the issue and that discovery would be needed to fully resolve the legal question, which we think should be decided in our favor when all of the evidence is in."

The Fantasy Sports Trade Association said fantasy sports are a game of skill and that the court "simply got it wrong."

"The FSTA is also disappointed that the New York Attorney General has chosen the path of hurried litigation after years of watching daily fantasy sports thrive and entertain in New York rather than pursuing the path of common sense regulation or legislation," the organization said in a statement.

Schneiderman had previously said that he was interested in having DraftKings and FanDuel undo their deals with teams within the state and stop advertising. Apron signage for the companies at New York Knicks and Brooklyn Nets games must come off for national games. It's not clear whether the companies would want their advertising on local broadcasts when New Yorkers can't use their services.

"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. "I have said from the beginning that my job is to enforce the law, and that is what happened today."

While much of the public argument was over whether daily fantasy was a game of skill or a game of chance -- as the Unlawful Internet Gambling Enforcement Act of 2006 provided fantasy with federal legality thanks to that reasoning -- that debate had little to do with Mendez's decision because that isn't the test within New York to determine whether games constitute illegal gambling.

The NBA owns equity in FanDuel, and Major League Baseball and the NHL own equity in DraftKings. The NBA and MLB did not immediately respond to requests for comment.

The NFL does not own equity in either daily fantasy operator, but almost all the league's teams have advertising partnerships with one of them. New England Patriots owner Robert Kraft and Dallas Cowboys owner Jerry Jones also own equity in DraftKings. The NFL declined comment.

The contention by the lawyers of DraftKings and FanDuel that seasonal fantasy is even less of a game of skill and therefore should also be banned played no role in the decision, because Mendez said the legality over seasonal fantasy is not what the court is charged to rule on.

At least 600,000 New Yorkers play daily fantasy on DraftKings and FanDuel, having put up more than $200 million in entry fees combined in 2015.

FanDuel, which has its main headquarters in New York, and DraftKings, which has a satellite office in New York but is based in Boston, can still operate their national businesses out of those Manhattan offices but cannot do business with anyone in the state.

Mendez pointed to the definitions of gambling and "contest of chance" as currently stated in New York Penal Law and ruled that the former had a greater likelihood of success, warranting injunctive relief.

The ruling comes just three days after the New York Assembly held a hearing on potential regulation of daily fantasy. During the Tuesday hearing, Assemblyman J. Gary Pretlow, who heads the Committee on Racing and Wagering, said the Legislature will likely legalize and regulate daily fantasy sports, regardless of how Mendez rules.

On Nov. 10, Schneiderman sent cease-and-desist demands to FanDuel and DraftKings. FanDuel stopped accepting New York residents in its paid contests in November, while DraftKings continued.

Both companies filed a petition against the attorney general seeking injunctive relief. A two-hour hearing was held Nov. 26, the day before Thanksgiving. Mendez took more than two weeks to announce his decision.