The loss by the once-favored Coakley for the seat that the late Sen. Edward M. Kennedy held for nearly half a century signaled big political problems for the president's party this fall when House, Senate and gubernatorial candidates are on the ballot nationwide.

More immediately, Brown will become the 41st Republican in the 100-member Senate, which could allow the GOP to block the president's health care legislation and the rest of Obama's agenda. Democrats needed Coakley to win for a 60th vote to thwart Republican filibusters.

Democratic fingerpointing began more than a week ago as polls started showing a tight race, with the White House accusing Coakley of a poor campaign and the Coakley camp laying at some of the blame on the administration. Obama flew to Boston for last-ditch personal campaigning on Sunday.

The election transformed reliably Democratic Massachusetts into a battleground state. One day shy of the first anniversary of Obama's swearing-in, it played out amid a backdrop of animosity and resentment from voters over persistently high unemployment, industry bailouts, exploding federal budget deficits and partisan wrangling over health care.

For weeks considered a long shot, Brown seized on such discontent to overtake Coakley in the final stretch of the campaign. Surveys showed his candidacy energized Republicans, including backers of the grass-roots "tea party" movement, while attracting disappointed Democrats and independents uneasy with where they felt the nation was heading.

Turnout was relatively heavy for a special election despite a mix of snow and rain showers across the state virtually all day.

Though he wasn't on the ballot, the president was on many voters' minds.

"I voted for Obama because I wanted change. ... I thought he'd bring it to us, but I just don't like the direction that he's heading," said John Triolo, 38, a registered independent who voted in Fitchburg.

He said his frustrations, including what he considered the too-quick pace of health care legislation, led him to vote for Brown.

But Robert Hickman, 55, of New Bedford, said he backed Coakley "to stay on the same page with the president."

Even before the first results were announced, administration officials were privately accusing Coakley of a poorly run campaign and playing down the notion that Obama or a toxic political landscape had much to do with the outcome.

Coakley's supporters, in turn, blamed that very environment, saying her lead dropped significantly after the Senate passed health care reform shortly before Christmas and after the Christmas Day attempted airliner bombing that Obama himself said showed a failure of his administration.

While votes were still being cast, White House spokesman Robert Gibbs said the president "was both surprised and frustrated ... not pleased" at how competitive the race had become in the final weeks.

Wall Street watched the election closely. The Dow Jones industrial average rose 116 points, and analysts attributed the increase to hopes the election would make it harder for Obama to make his changes to health care. That eased investor concerns that profits at companies such as insurers and drug makers would suffer.

Across Massachusetts, voters who had been bombarded with phone calls and dizzied with nonstop campaign commercials for Coakley and Brown gave a fitting turnout despite intermittent snow and rain statewide.

Secretary of State William Galvin, who discounted sporadic reports of voter irregularities throughout the day, predicted turnout ranging from 1.6 million to 2.2 million, 40 percent to 55 percent of registered voters. The Dec. 8 primary had a scant turnout of about 20 percent.

Voters considered national issues including health care and the federal budget deficits.

"We don't want health care just for the rich and the middle class. We need it for everyone," said Democrat Neicei Degen, 82, who voted for Coakley in hopes of saving Obama's plan that would extend coverage to millions of uninsured.

Fears about spending drove Karla Bunch, 49, to vote for Brown. "It's time for the country, for the taxpayers, to take back their money," she said.

For others, feelings about the candidates themselves shaped their votes.

Recalling that Brown once posed nude for Cosmopolitan magazine, Kaitlin Addams, 50, said she reluctantly voted for Coakley "to make sure the pinup boy doesn't get into office. I don't like his stand on issues. He's an extreme conservative."

Conversely, Elizabeth Reddin, 65, voted for Brown because she said she was turned off by the Democrat's negative advertisements, saying: "The Coakley stuff was disgusting."

As polls opened, Brown drove up to his polling place in Wrentham in the green pickup truck that came to symbolize his upstart, workmanlike campaign that in the past week pulled him into a surprise dead heat in polls.

"It would make everybody the 41st senator, and it would bring fairness and discussion back to the equation," the state senator said of a potential victory. He spent the rest of the day out of public view, crafting evening rally remarks that had the potential to be an early State of the Union speech for the national Republican Party.

Coakley, stunned to see a double-digit lead evaporate in recent weeks, counted on labor unions and reawakened Democrats to turn out on her behalf and preserve a seat Kennedy and his brother, President John F. Kennedy, held for over 50 years. The senator died in August of brain cancer.

"We're paying attention to the ground game," Coakley, the state's attorney general, said casting her vote in suburban Medford. "Every game has its own dynamics."