Drawing on the political might of the White House, Democrats have exorcized the ghost of Scott Brown.

Three years after the little-known Republican state senator shocked the political world with an unlikely victory here, veteran Democratic U.S. Rep. Ed Markey won the special election Tuesday for U.S. Senate to replace John Kerry, defeating a Republican political newcomer with an all-star resume who failed to inspire Massachusetts voters and Washington’s GOP leaders alike.

It was a resounding victory in a low-turnout election for a national Democratic Party still haunted by Brown’s 2010 special election stunner.

“To everyone in the state, regardless of how you voted, I say to you tonight this is your seat in the United States Senate,” Markey, 66, declared in his victory speech, echoing one of Brown’s most common lines.

The contest served as a reminder that President Barack Obama has vowed to play a more aggressive political role for his party through next year’s midterm elections with huge stakes for his legacy and final-term agenda. Democrats face several competitive Senate contests in less-friendly terrain in 2014, when their grip on the Senate majority will be tested.

The White House, led by Obama himself, invested heavily in the Massachusetts election, fueled largely by widespread fear of another Brown-like surprise.

“The people of Massachusetts can be proud that they have another strong leader fighting for them in the Senate, and people across the country will benefit from Ed’s talent and integrity,” Obama said in a statement Tuesday night.

Republicans claimed a moral victory of sorts, having forced Democrats to deploy their biggest political stars in an election in which Markey enjoyed significant advantages in Democrat-friendly Massachusetts. Markey’s victory follows personal visits by Obama, first lady Michelle Obama, Vice President Joe Biden, former President Bill Clinton and Democratic National Committee chairwoman Debbie Wasserman-Schultz.

“Not every fight is a fair fight,” Gomez said in his concession speech. “Sometimes you face overpowering force. We were massively overspent. We went up against literally the whole national Democratic Party. And all its allies.”

From the beginning, it appeared that national Democrats were more committed to the contest than national Republicans, raising questions about the GOP’s commitment to candidates who might help improve the party’s appeal after a painful 2012 election season.

Washington Republican leaders distanced themselves from Gomez partly by design. The 47-year-old businessman attacked Markey as the ultimate Washington insider and was reluctant to link himself to the same national forces he condemned. But as Democrats poured money and manpower into Massachusetts, Gomez needed help to capitalize on Markey’s weaknesses.

U.S. Sen. John McCain of Arizona and former New York Mayor Rudy Giuliani campaigned in Boston for Gomez.

But what help he got appeared to be too little, too late.

“It’s unclear whether Republicans in Washington intended to compete in this race and truly let an opportunity slip away or they were just blowing smoke the whole time,” Guy Cecil, executive director of the Democratic Senatorial Campaign Committee, wrote in a postelection memo.

Both sides conceded that Markey was not a perfect candidate.

The senator-elect, who first became a congressman in 1977, struggled to connect with voters at times on the campaign trail. He also faced repeated questions about whether he was a full-time resident of Washington or Massachusetts.

On paper, Gomez’s credentials appeared to fit the gold standard for the new breed of mass-appeal Republican that the GOP wants as it works to improve its standing among women and minorities. A former Navy SEAL turned businessman, Gomez speaks Spanish, supports immigration reform and moderate positions on social issues – characteristics the Republican National Committee recently called for in a postelection internal autopsy as key to GOP growth.

Washington’s traditional Republican campaign apparatus sent Gomez some paid workers and campaign cash, but Markey and his national allies dramatically outspent Gomez’s side. The disparity was fueled by Gomez’s inability to attract pro-Republican super PACs that funneled hundreds of millions of dollars into elections to help Republican candidates last fall.

At the same time, Gomez’s moderate positions alienated the GOP’s most passionate voters. The national tea party movement that helped fuel Brown’s rise sat out the race.

“Gomez left his base unenthused and unexcited,” said Sal Russo, chief strategist to the Tea Party Express, which was among the first national groups to help Brown’s 2010 campaign. “When a Republican tries to look like a Democrat-light, what Democrats do is vote for a Democrat. You have to create some contrast.”

Still, Republicans suggest that Markey’s need to involve the White House could mean trouble for Democrats in the midterm elections.

Almost immediately after winning re-election, Obama vowed to go all out for his party for the 2014 elections, mindful that sending more Democrats to Congress could be the difference between success and failure for key aspects of his second-term agenda like immigration, climate change and a budget deal.

Already, Obama and the first lady have hit the campaign trail with vigor this year, traversing the nation to raise money and rally support for Democratic candidates and the committees that work to elect them. In addition to Massachusetts, the president has campaigned this year in California, Texas, Illinois, New York and Georgia. But Republicans and Democrats agree that Obama’s direct involvement would be less helpful in competitive 2014 Senate contests in states such as South Dakota, West Virginia, Arkansas and Iowa, where he’s not as popular as in Massachusetts.

“The national climate for Democrats is not good,” said Republican strategist Ron Kaufman, also a Massachusetts national Republican committeeman. “I promise it’s not good in places like Iowa and the Dakotas where we have open Democrat seats.”

Meanwhile, Gomez’s future is unclear.

He said this week that, win or lose, he’d be willing to help the GOP expand its appeal among the nation’s growing Hispanic population. And he has repeatedly hinted that his political career would not end Tuesday.

“In the future, we are going to be better,” Gomez said in Spanish at the end of his concession speech.

Markey, who serves out the rest of Kerry’s term, faces his first re-election test in 2014.