BOSTON – House lawmakers approved a bill Wednesday to license two resort-style casinos and allow up to 3,000 slot machines at the state’s four race tracks, bringing Massachusetts a step closer to the largest expansion of gambling since the creation of the state lottery in 1971.

The 120-37 vote marks a dramatic shift in the House, which just two years ago voted 106-48 against a similar bill by Gov. Deval Patrick to license three destination casinos. Dozens of lawmakers switched their vote to support DeLeo’s bill.

The vote was a major victory for Democratic Speaker Robert DeLeo, who succeeded in persuading enough House lawmakers to back the measure to withstand a potential veto by Patrick, who opposes racetrack slots. Patrick has not said whether he would veto the bill.

DeLeo needed at least 106 votes to make the bill veto-proof. He called the bill “the envy of every other state.”

The vote came after two days of impassioned debate during which lawmakers beat back dozens of amendments including a Republican-led effort to send the bill back to committee to allow a public hearing on the legislation.

The bill now heads to the Massachusetts Senate.

Supporters say the bill would produce a major economic jolt for the state, allowing it to recapture up to half of the money spent by Massachusetts residents at casinos in neighboring states.

House leaders say that translates into between $300 million and $500 million in added tax revenues each year, while creating up to 19,000 jobs.

Opponents say the promise of a revenue windfall and thousands of good-paying jobs is overblown.

Rep. Daniel Bosley, D-North Adams, a longtime foe of expanded gambling, said lawmakers have failed to have a serious debate about the basic assumptions about how much money casinos may or may not bring into the state.

“This does not have to be our economic future,” Bosley said. “I’m not morally opposed to casino gambling, it’s just lousy economic policy.”

Bosley and others said House leaders should have commissioned a new fiscal review of the bill that looked at the potential costs of casinos, both in social woes like divorces and bankruptcies and the financial hit to some local businesses and performing arts centers.

But those concerns largely fell on deaf ears as lawmakers, facing tough re-election campaigns in the fall, groped for anything they could help boost tax revenues and create jobs.

Rep. Kathi-Anne Reinstein, D-Revere, a backer of casinos, said the state’s racetracks, which would benefit under the bill, have provided good jobs for generations of workers. Reinstein herself worked at the Wonderland Greyhound Park.

“These facilities, these businesses, were never considered albatrosses,” she said. “They brought opportunity to the district.”

The debate turned emotional at times.

Rep. Matthew Patrick, D-Falmouth, was near tears as he recalled the struggles his family went through as his father, a World War II veteran and biology teacher, lost money at a nearby horse track, leaving his 10 children on the brink of poverty.

“This has real dramatic impacts on families,” Patrick said. “It’s going to hurt families.”

Chip Tuttle, chief operating officer at Suffolk Downs, one of the state’s two horse tracks, welcomed the vote and said the track, in partnership with Wonderland Park, is “committed to building and operating a world-class entertainment complex that combines restaurants, retail, racing, gaming and a hotel.”

During the debate, lawmakers rejected a series of amendments.

One would have barred casinos from pumping pheromones into the air to encourage patrons to keep gambling.

Other failed amendments would have set a $500 limit on how much an individual could lose in a single day, prohibited the use of “luck ambassadors” to urge people to keep betting, placed warning labels on all casino marketing materials and required a public health official to intervene if someone continued betting for more than 12 hours straight.

Rep. Brian Dempsey, House chairman of the Committee on Economic Development Committee, defended the bill and the decision to rely on an updated version of a 2008 economic study of Patrick’s three-casino bill. Dempsey said that while the two bills are different, the updated study showed “a very strong marketplace” for casino gambling in New England.

Under DeLeo’s proposal, all the revenues from the racetrack slots, up to $100 million a year, would be returned to cities and towns as local aid.

Two of the state’s racetracks are located in the Winthrop Democrat’s district. The state’s two dog tracks have struggled since Massachusetts voters opted to ban live dog racing.

The bill requires a $500 million private investment from each of the resort casinos and $75 million from each of the race tracks and would deliver $260 million in upfront licensing fees to the state.

The lure of casinos has drawn millions in lobbying dollars to Massachusetts.

The amount spent by firms, unions and interest groups hoping to influence the debate has grown from just more than $800,000 in 2006 to more than $2 million in 2009, according to an Associated Press review of records filed with the Secretary of State’s Office.

The vast majority of the lobbying dollars are being spent by groups hoping to get a piece of the gambling pie if lawmakers ultimately vote to expand gaming.