Thousands of slot machines were headed for Maryland as voters Tuesday backed a ballot referendum supporting the expansion of legalized gambling which Gov. Martin O’Malley called critical to narrowing state budget gaps.

After years of debate by state legislators, voters finally approved installing 15,000 slots machines to racetracks in Allegany, Anne Arundel, Cecil and Worcester counties and Baltimore City. The measure gained support all across the state, including Montgomery and Prince George’s counties, where opposition was believed to be strongest.

Slots proponents, who outspent anti-slots groups by roughly 7 to 1, said Monday residents would back the measure as a way to keep local schools from being slashed. Slots were also backed by firefighters, police and teachers unions who saw the added revenues as indirect protection against cuts to their agencies.

Opponents, including a consortium of religious leaders and some state officials who said slots would siphon income from the poor, had hoped to pull off an upset and defeat the measure.

There were no surprised in congressional races in Maryland’s Washington suburbs. Democratic Reps. Donna Edwards, Chris Van Hollen, Steny Hoyer were all on track to relatively easy victories. Republican Roscoe Bartlett also won by a wide margin.

Meanwhile, watchdog group Common Cause Maryland reported 188 voting-related problems as of 3:30 p.m., mostly related to lines. Voters at Illchester Elementary School in Ellicott City — where one precinct votes in the gym, and another in the cafeteria — said many waited in long lines only to realize they stood in the wrong one.

Two Maryland residents reported receiving text messages on their cell phones instructing Barack Obama supporters to cast their ballots Wednesday, according to David Roach, an attorney with the American Civil Liberties Union of Maryland.

Lines were long throughout the Maryland suburbs. But voters didn’t seem to mind. At a polling place near Shady Grove metro in Montgomery County, Ron Brown of Derwood said it was well worth the 40-minutes he waited to vote. His wife, Betty, who he said held opposite political views, had voted earlier in the day. “I have to stay and cancel her out,” he said.

Examiner Staff Writer Jamie Malarkey and Managing Editor Mike Hedges contributed to this story.