ATLANTIC CITY, N.J. — The anticipation of legal sports gambling throughout the United States has prompted a flurry of deals among gambling and technology firms that want a foothold in a market worth billions.

Casinos, race tracks, daily fantasy sports companies and others are itching to offer bets in person and online after the Supreme Court ruled Monday that states could begin allowing wagers.

That's led companies all over the world to seek ways to team up.

Some casinos need mobile apps or someone to set lines and run sports books that operate much differently than slot machines and table games.

Many tech firms, daily fantasy sports companies and others need gambling licenses and experience with significant regulation.

Other companies that handle data security and payment processing are also joining the fray.

The industry is preparing for most of the betting to happen on smartphones, just like in Europe.

That would also be new for most U.S. states, as internet gambling has been limited to just three states in recent years.

"This is a multibillion-dollar industry that has been operating in darkness and can now be brought into the light with legalization and regulation," said Richard Schwartz, president of Rush Street Interactive, which operates SugarHouse Online Casino, a gambling site for New Jersey residents that offers slots and table games.

Churchill Downs, the race track that runs the Kentucky Derby, said Wednesday it inked deals with a tech company for its platform and the Golden Nugget casino in Atlantic City for its license in New Jersey.

It bought Presque Isle Downs & Casino in Pennsylvania in March and owns two casinos in Mississippi, with plans to offer sports betting in all three states.

Dublin-based gambling firm Paddy Power Betfair has an online casino in New Jersey but is considering merging its U.S. business with FanDuel, the popular daily fantasy sports company, in a deal with clear upside for both sides.

Betfair would gain a well-known American brand with millions of customers built on technology that could be used for sports betting.

FanDuel, meanwhile, would need expertise on complex regulation if it hopes to gain a casino license, a move that most fantasy sports companies tried for years to avoid by arguing that fantasy sports doesn't amount to gambling.

Anticipation of the ruling even prompted some companies to squash their differences and focus on the potential windfall.

London-based bookmaker William Hill had threatened to use its stock to derail a buyout between two online gambling infrastructure firms in Las Vegas. But it later agreed to support the purchase of NYX Gaming by Scientific Games.

The opportunities are vast for companies that can help customers turn from illegal bookies and offshore operations, said Laila Mintas, deputy president of Sportradar, a New York company that works with more than 70 sports federations and leagues around the world on fraud detection, including the NBA, NHL and MLS.

"It opens the door for all different stakeholders such as the states, the leagues, the casino and lottery industry to act quickly and to benefit," she said.