Massachusetts voters have elected Democrat Elizabeth Warren to the U.S. Senate, rejecting Republican incumbent Scott P Brown in favor of a first-time candidate who vowed to “work her heart out” for the middle class.

The 63-year-old Harvard Law School professor and consumer advocate prevailed over Mr. Brown in the most expensive Senate race in the country, becoming the first woman ever elected to the Senate from Massachusetts.

“This victory belongs to you. You did this. You did this,” Ms. Warren told her supporters in a victory speech interrupted by load chants of “Warren, Warren, Warren.”

She pledged to fight for families who have been “chipped at, squeezed and hammered” and said she would fight to make sure “millionaires and billionaires pay their fair share.”

“You taught a scrappy first-time candidate how to get in the ring and win,” she said to her backers. “You let them know you want a senator that will be out there fighting for middle class all of the time. And you elected the first woman senator, too,” she said. “All of you have had my back and I promise you, I'll have your back,” Ms. Warren said thanking what she called, “the single best grass-roots army” the state had ever seen.

The contentious $70 million race that unfolded amid a highly partisan national election returns the seat long held by the late Sen. Edward M. Kennedy to the Democratic ranks and could be a factor in which party controls the Senate.

Polls showed a tight race heading into Election Day and today's outcome derails Mr. Brown's rise to power and popularity that began Jan. 19, 2010, when the Wrentham state senator surprised many with an upset special election victory to serve out the remaining three years of Mr. Kennedy's term.

Mr. Brown consoled his supporters at the Park Plaza Hotel saying, “I don't want to see any sad faces. We ran a fantastic campaign.” He congratulated his opponent in his concession speech and said he accepted the results.

“If you run for office you have to be able to take it either way, winning or losing,” Mr. Brown told them. “She won it fair and square folks and she has won a high honor winning the people's seat. It's absolutely been a wonderful ride and I want to thank you for the honor of being your United States senator,” he said.

He said he didn't regret a single decision he made in his less than three years in the Senate and hinted that he's not leaving politics permanently.

“There are no obstacles you can't overcome, and defeat is only temporary,” he said to loud cheers.

State elections officials said there was a historic turnout and there were still long lines of voters waiting to cast ballots after the 8 p.m. closing time in many precincts. Lt. Gov. Timothy P. Murray said Democrats put on the best get out the vote operation ever in Worcester County.

Warren supporters who jammed into the ballroom of the Copley Fairmont Hotel tonight erupted with euphoric shouts and howls when they saw the three major networks project Ms. Warren as the winner shortly before 10 p.m. They also cheered with glee as state-by-state wins by President Barack Obama were announced on giant television screens set up for them to watch election coverage.

Gov. Deval L. Patrick thanked Ms. Warren for showing political courage to get into the race, saying "Our next great senator is a person with backbone."

Renewing his promises to repeal Obamacare and battle tax increases and deficit spending, Mr. Brown attacked Ms. Warren's character and career, laid claim to political independence and asked voters to back his hope to find bipartisan solutions to the nation's deep economic problems.

“I'm nobody's senator except yours,” Mr. Brown vowed in his closing ads, asking voters to “Vote the person, not the party” in the intensive and high-priced campaign that left the race too close.

But Ms. Warren took the upper hand today as Democrats launched highly developed “get out the vote” operations that saw thousands of campaign volunteers canvassing neighborhoods for months to target supporters and ensure they got to the polls.

At a final campaign stop at the Broadway Diner in Worcester yesterday, Ms. Warren laid out what she thought was at stake in the election.

“This truly is about what kind of a people we are, what kind of a country we are going to build,” she said. “The people of Massachusetts can keep a senator who stands with the millionaires and billionaires or they can elect a senator who will be out there every day fighting for working families.”

Throughout the campaign, Ms. Warren disputed Mr. Brown's claim to political independence, pounding on his record of opposing Obamacare, job creation bills, birth control coverage, and middle-class tax cuts, unless taxes were also cut for the top 2 percent.

In three debates, millions of dollars in television ads and on the stump, she said voters, “deserve a senator you can count on all of the time, not just some of the time.”

Ms. Warren also pledged to back federal investments in education, research and infrastructure and to oppose any cuts in Social Security and Medicare benefits, while getting substantial help from most of the state's teacher, fire and building trades unions. Her campaign was bolstered by coordinated support from the state's major Democratic figures, including Gov. Deval L. Patrick and Lt. Gov. Timothy P. Murray, Boston Mayor Thomas M. Menino, the state's congressional delegation and a coalition of Central Massachusetts Democrats led by U.S. Rep. James P. McGovern.

Ms. Warren began her first run for elective office last year, encouraged by Senate Majority Leader Harry Reid to enter the race. She secured a direct path to the November election when delegates to the state Democratic convention in Springfield denied immigration attorney Marissa DeFranco enough votes to force a primary.

Her candidacy was not without bumps.

In debates, Mr. Brown kicked off their first two of three debates with accusations that Ms. Warren falsely claimed Native American heritage to get hired to teach at the University of Pennsylvania and at Harvard Law School decades ago.

But Ms. Warren defended her family heritage claims as being based on accounts that she grew up with in her family. She cited testimony from officials who hired her at Harvard that she did not use the claim to get hired and the Brown campaign was unable to document the accusations that she “checked the box” as a minority when she applied for jobs at those schools.

Mr. Brown's campaign promoted his everyman image, support for Boston sports teams, dedication to veterans, his claim of political independence and successes in getting several bills passed with bipartisan support.

Both candidates barnstormed the state for weeks in the final phase of the campaign, which was brought to a halt a week before Election Day when Hurricane Sandy shut down the state and forced cancellation of the last debate in Boston.

Mr. Brown made the decision not to participate in a rescheduled debate Thursday, opting for a final five-day bus tour across the state, drawing rebukes from Ms. Warren. He brought in Sen. John McCain, R-Arizona, New Jersey Gov. Chris Christie and former New York Mayor Rudy Giuliani to campaign with him, but avoided appearances with GOP nominee Mitt Romney, the former Massachusetts governor.

Ms. Warren, meanwhile, barnstormed the state in her hybrid Ford Escape, embracing crowds and building local volunteer networks. Both candidates held numerous campaign events in Central Massachusetts, which was viewed as a key swing county in the statewide vote.

Priyanka Dayal McCluskey of the Telegram & Gazette staff contributed to this report.