Officials across sports have for years complained that legalized wagering would lead to the corruption of their games through match-fixing, though there is no indication that is a realistic concern. Sports betting is legal and wildly popular in Britain, for example, but the integrity of the Premier League has not suffered. In fact, legalizing gambling allows companies and leagues to monitor gambling patterns and flag betting irregularities that could suggest corruption.

In recent years, the professional sports leagues have taken varying positions. Nominally, they are all against it: When New Jersey repealed its law against sports betting, the N.B.A., the N.F.L., the N.H.L., and the M.L.B., as well as the N.C.A.A., which governs college sports, joined together to sue the state. They were on the losing side of Monday’s ruling.

While the N.F.L. and the N.C.A.A. have been the most steadfast in their stance against legalized sports betting, the N.B.A. long ago concluded that public opinion had shifted, that bringing the gray- and black-market betting into the legal market would be the best way of preventing match-fixing, and that there is money to be made for the leagues.

In 2014, Adam Silver, the N.B.A.’s commissioner, wrote an Op-Ed for The New York Times advocating the legalization and regulation of sports betting. In an appearance for a New York Senate committee in January, a league official laid out the N.B.A.’s opinion on its ideal sports betting legislation that would, among other things, establish monitoring to detect unusual betting activity; impose a 1 percent “integrity” fee on bets that would be paid to sports leagues; and authorize digital betting platforms in addition to brick-and-mortar casinos.

In the months since, the N.B.A. and the M.L.B. have toured state legislatures lobbying lawmakers for the rules.

The leagues are not the only stakeholders trying to shape legislation. Unions representing professional athletes like the baseball players’ association have demanded a seat at the table, while casinos and gambling trade groups have opposed any calls for an integrity fee. Native American tribes, which generate over $30 billion in casino revenue annually, have mostly taken a wait-and-see approach to sports betting, but will surely want a say in how laws are crafted.

Finally, there is always a chance Congress could get involved.

“Congress can regulate sports gambling directly, but if it elects not to do so, each state is free to act on its own,” Justice Alito wrote in his majority opinion.