Fantasy sports contests like those operated by FanDuel and DraftKings were declared constitutional in New York on Tuesday by the state's highest court.

The state Court of Appeals reversed an appeals court's decision last year that found daily fantasy sports violated the state constitution’s ban on gambling. The games allow players to assemble a roster of athletes in a sport, using individuals performance statistics to determine the winner.

The lawsuit was brought several years ago and did not target mobile sports betting, which began in New York earlier this year.

In a 4-3 ruling, New York's top court clarified the scope of the state's prohibition on gambling. Chief Judge Janet DiFiore wrote that games in which skill predominates over chance and skill-based competitions for prizes in which the players have influence over the outcome do not constitute gambling under the state constitution.

DiFiore wrote that the outcome of a interactive fantasy sports contest "turns — not on the performance of real-life athletes, as it would with respect to a bet or wager — but on whether the participant has skillfully composed and managed a virtual roster so as to garner more fantasy points than rosters composed by other participants.”

The fantasy sports measure signed into law by then-Gov. Andrew Cuomo in 2016 cleared the way for companies like DraftKings and FanDuel to operate and be regulated in New York.

“New York state is FanDuel’s home and our New York customers have enjoyed playing daily fantasy for years. We are pleased that New Yorkers will continue to have access to fantasy sports contests,” FanDuel spokesperson Kevin Hennessy said in a prepared statement.

The lawsuit challenging the constitutionality of the law was coordinated by the group Stop Predatory Gambling on behalf of four plaintiffs who had suffered personal or family harm from gambling debts.