The future of fantasy sports betting in New York is unclear after a state court ruled today that a law legalizing the industry violates the New York state constitution.

New York's constitution contains a ban on most gambling, with some exceptions: state-run lotteries, horse races, approved casinos, and various low-level community charitable gambling activities. In 2016, after making sure that New York's government would get a nice cut of the revenue from fantasy sports games, lawmakers passed legislation amending state gambling law to allow for fantasy sports betting.

Daily fantasy sports betting (DFS for short) is similar to the fantasy sports leagues hosted by sites like Yahoo! and ESPN (old-fashioned rotisserie leaguers may remember keeping score with pen and paper). The two major differences are these: instead of drafting a team of real-life athletes whose stats you count over the course of a year in order to beat your friends and coworkers, DFS betting lets you put together a roster for just one day or night of games. The other major difference is that DFS betting sites and apps let you put real money behind your lineup.

But it turns out there's a problem with the state's law legalizing DFS betting (what New York refers to as "Interactive Fantasy Sports" or IFS). In order to bypass the state constitution's ban on gambling, lawmakers had to declare that fantasy sports betting is not a form of gambling. In other words, they didn't create an actual exemption for DFS betting in the law, the way the state constitution has done for horse racing; legislators simply declared that DFS betting is not gambling.

The law was challenged in White v. Cuomo by plaintiffs looking to stop its implementation. Today, the state's Supreme Court Appellate Division ruled in favor of the plaintiffs. In a somewhat technical ruling, the judges rejected the state lawmakers' attempt to redefine DFS betting. Such contests "are not excluded from the constitutional meaning of 'gambling' merely because the Legislature now says that it is so," reads the ruling.

A good chunk of the decision is based around how much of DFS betting relies on chance. While the ruling acknowledged that there's skill involved in playing fantasy sports, there's still a "material degree of chance" because outside, uncontrollable forces may affect the outcome: "Among other things, player injury or illness, unexpected weather conditions, poor officiating, a selected player having a particularly bad day or an unselected player having a surprisingly good day."

And because chance influences the outcome of DFS betting, it is gambling. And because most gambling is outlawed by the state's constitution, lawmakers can't get around the ban by claiming that DFS betting doesn't count as betting. With only Justice Stan Pritzker dissenting, the New York Supreme Court Appellate Division declared the law invalid.

This does not immediately mean the end of fantasy sports betting in New York. Rob Rosborough, who writes about the legal fight for a blog devoted to covering New York's Appeals Court, notes that the state will automatically be granted a stay if it appeals the ruling. That would mean FanDuel and Draft Kings and other sites like them could continue operating.

But if the ruling is upheld, New York would need to amend its constitution. That process requires both houses of the state legislature to pass the amendment, which would then go before voters in the form of a ballot initiative.

Watch more about the complex DFS betting fight from ReasonTV below: