Online wagering will not begin until 30 days after the law is signed.

Some legal experts said starting online wagering quickly is essential. Cutting into the black market, where gamblers can place bets from the comfort of their couches, will require making legal betting as effortless as possible.

“You’re providing less of an incentive to customers to enter or migrate over from a black market to legal and regulated channels,” said Daniel L. Wallach, a lawyer from Florida who has followed New Jersey’s sports betting efforts. “Convenience will always trump driving 20 or 30 miles.”

The amount of money that the state can expect to reap from sports betting is unclear. Some lawmakers have estimated that wagering could yield as much as $100 million during the first year, but the state treasurer, Elizabeth Muoio, has put it much lower, at $13 million.

What the state’s law does make clear is that no money will go to any professional sports league. In a contentious hearing on Monday, Major League Baseball, the N.B.A. and the Professional Golfers Association lobbied for an “integrity tax” to help pay for increased security to protect against cheating and to enhance statistical operations for real-time data used for in-game betting.

Lawmakers were not moved.

“You guys are in it to make money,” said Assemblyman Ralph Caputo, a Democrat from northern New Jersey and chairman of the Tourism, Gaming and the Arts committee. “This is hypocrisy. Nine years of fighting the State of New Jersey, and you come here? It’s disgraceful. Just a suggestion: You may want to write a check to the State of New Jersey for $9 million.” That was a reference to the state’s cost to fight the leagues in court.

The bill sets the legal betting age at 21, even though the age to bet on horse races in New Jersey is 18. It allows betting on all professional sports, but it bans betting on collegiate athletics that take place in New Jersey or on college teams from New Jersey, like Seton Hall and Rutgers. The bill also bans betting on high school games and on the increasingly popular electronic sports leagues.

The bill was amended at the last minute to allow betting before Mr. Murphy signs the legislation. That could let Monmouth Park, which has a sports betting operation ready to go, welcome gamblers as soon as Friday.