BOSTON 
In a reversal from the last Massachusetts Senate race, Democrats yesterday garnered enough votes among their base and independents to propel Elizabeth A. Warren to victory.

Ms. Warren, a Harvard Law professor, defeated incumbent Scott P. Brown to reclaim for Democrats the U.S. Senate seat long held by the late Edward M. Kennedy.

She won in urban areas like Boston and Worcester and closed the gap in suburban areas that slimly chose Mr. Brown two years ago.

Mr. Brown won all of Central Massachusetts except Worcester and Harvard when he defeated Attorney General Martha Coakley in a special election in January 2010.

This time, Ms. Warren won Worcester and Harvard, but also Fitchburg and Southbridge, according to unofficial results. Though Mr. Brown won most of Central Massachusetts, Cape Cod and the northeastern part of the state, he won many communities by smaller margins than he did against Ms. Coakley.

“She did very well in Worcester,” U.S. Rep. James P. McGovern, D-Worcester, said shortly after the race was called.In Worcester, she bested Mr. Brown 36,572 to 22,060, or 62 percent. She won Boston and Springfield, receiving 74 percent of the vote in both cities. She tallied 68 percent in both Fall River and Brockton and 59 percent in Lowell.

The race, the most expensive Senate contest in the country this year, wasn't as close as some polls suggested.News organizations started calling the race for Ms. Warren a little more than two hours after the polls closed. She took 54 percent of the vote, while Mr. Brown earned 46 percent, according to the Associated Press.

Roberta R. Goldman, a member of the Massachusetts Democratic State Committee celebrating at Ms. Warren's campaign headquarters at the Fairmont Copley Plaza, noted that support for Mr. Brown faded in her hometown of Shrewsbury. “We gained five more percentage points, she said. “It went to Brown, but not as strongly.”

Ms. Warren not only brought out the urban vote, but penetrated the suburban vote, Ms. Goldman said.

An advocate of consumers and the middle class who served as an advisor to President Barack Obama, Ms. Warren was helped by the surge of voters who came out to cast their ballots for the president. Mr. Obama won Massachusetts with 61 percent of the vote, an easy win over the roughly 37 percent captured by former governor Mitt Romney.

“It is always difficult to run as a Republican in a presidential election in Massachusetts,” said Worcester County Sheriff Lewis G. Evangelidis, a Republican, who joined other Scott Brown supporters at the campaign's election night event at the Park Plaza Hotel.

“I'm proud of the race he ran,” Mr. Evangelidis said. “This was a close race.”

Peter Ubertaccio, chairman of the Department of Political Science & International Studies at Stonehill College, said Mr. Brown, who was seen in his last campaign as a positive person, did himself no favors by attacking Ms. Warren about her race.

The senator accused Ms. Warren of using her heritage -- she says she is part Native American -- to advance her career and being untruthful about it.

“He needed to move Democrats and independents, and there was no polling that showed that this was moving those voters,” Mr. Ubertaccio said.

The Warren campaign's ground game, though, was a big part of the victory, supporters said. Volunteers were knocking on doors through Election Day to try to get out the vote.

Mr. McGovern, who was at an event with Democrats in Worcester after the polls closed, said the campaign didn't take any votes for granted. Less than an hour before the polls closed, for example, volunteers helped a woman in a wheelchair get to her polling station, he said.

“Every single vote, we fought for,” he said. “This was a tough battle and a hard-fought race.”