Markey's victory, built in urban centers, affluent suburbs and the liberal environs of western Massachusetts, marked a full restoration for Massachusetts Democrats still smarting from Republican Scott Brown's upset victory in the state's last U.S. Senate special election in 2010.

U.S. Rep. Edward Markey, a Malden Democrat who has spent decades shaping energy, environmental and telecommunications policy in relative obscurity, won a promotion to the U.S. Senate Tuesday night after defeating Republican Gabriel Gomez in a special election.

Markey’s victory was built in urban centers, affluent suburbs and the liberal environs of western Massachusetts.

It also served as a measure of vindication for a candidate criticized for a safe and, at times, less-than-energetic campaign.

"This election is about your hopes, your dreams, your families, your future," said Markey, 66, before supporters at the Park Plaza Hotel in Boston. "And I know that. And I'm going to remember that."

Gomez, a former Navy SEAL, thanked cheering supporters at the Seaport Hotel in Boston.

"Not every fight is a fair fight," he said. "We were massively overspent...We went up against literally the whole national Democratic Party and all its allies and the machine. But in the face of this great adversity, we could not have fought a better fight."

Markey beat Gomez 55 percent to 45 percent. (How'd your town vote? See our town-by-town map.)

He will finish the term of former U.S. Sen. John Kerry, who left his post in January to serve as U.S. secretary of state.

In 17 months, he will have to run for re-election. It is unclear if his 10-point margin of victory Tuesday night — solid, but not overwhelming — will dissuade would-be challengers.

Gomez made no mention of his political future in his concession speech. But the National Republican Senatorial Campaign publicly encouraged him to run for the seat again.

Markey's lead on Gomez, in the compressed general election, was never yawning.

The first public poll gave him just a four-point lead. And the GOP candidate made Democrats nervous.

Gomez, 47, offered a fresh face and a compelling biography: The son of Colombian immigrants, he went from Harvard Business School, to the Navy, to a lucrative career in private equity.

He also cast himself as a "new kind of Republican." He supported gay marriage. He said he believes in manmade climate change. And he pledged to be a voice for immigration reform.

The comparisons to Brown, whose newcomer appeal helped propel him to victory in 2010, were inevitable.

But Democrat Elizabeth Warren, who ousted Brown from the Senate in the fall, found success wedding her opponent to the national GOP.

And Markey pursued a similar strategy from the get-go — tying Gomez to Washington Republicans on abortion, guns and Social Security.

It was a message he repeated — in television advertisments and on the podium — right through the end of the campaign.

"My opponent says he's a new kind of Republican," said Markey, at a Worcester rally last week, "but he backs the oldest, stalest Republican ideas from the past."

The Democratic Party, caught flat-footed 2010, was determined to do better this time: pairing Markey's message with an all-out ground game.

President Obama, former President Bill Clinton and Vice President Joe Biden all campaigned for Markey in the closing weeks of the campaign. And the party's foot soldiers targeted 3 million voters through door knocks and phone calls over the final five days of the race.

Outside groups backing Markey — including the Democratic Senatorial Campaign Committee, a Democratic super PAC known as Senate Majority PAC and environmental groups like the League of Conservation Voters — spent at least $4.8 million on television ads and get-out-the-vote operations.

National Republicans, by contrast, never bought into Gomez's candidacy.

Americans for Progressive Action, a conservative super PAC backed by a California vinter, poured at least $1.3 million into the race. But many of the biggest national players sat out the contest — a source of consternation for operatives in and around the Gomez campaign.

Gomez, at a financial disadvantage, also struggled to find a message that could motivate.

In 2010, Brown rode frustration over the economy and President Obama's healthcare reform to victory. But there was no similar discontent for Gomez to tap. And polls suggest his central message — that Markey is a tired Washington insider — didn't resonate.

Establishment Democrats rallied around Markey as soon as it became clear that Kerry would leave his U.S. Senate seat. In the end, he faced just one Democratic challenger — U.S. Rep. Stephen Lynch of South Boston, dispatching him easily in the party primary.

In the minority party for much of the last two decades in the House of Representatives, Markey will be in the majority in the U.S. Senate.

In his victory speech Tuesday night, he suggested he will focus on many of the issues that animated his House career.

"I want to lead the effort to launch a clean energy revolution in our country," he said, adding later, "we can combat climate change, break our dependence upon imported oil, and create jobs here in Massachusetts and across our country."

Markey joined with U.S. Rep. Henry Waxman, a California Democrat, to push a landmark climate change bill through the House in 2009. But the measure died in the Senate.

And it's not clear that major environmental legislation will fare any better in the Senate going forward, with the filibuster serving as an ever greater obstacle to change.

The special U.S. Senate race never generated much enthusiasm with the Bay State electorate. And turnout Tuesday was poor, with just 27 percent of eligible voters casting ballots — about half the turnout in the 2010 special election.

Markey built large margins in urban centers like Boston, Worcester and Springfield. Boston's northern and western suburbs, including those in Markey's Congressional district, also delivered big victories to the Democrat.

Gomez was strong in more conservative parts of the state — the South Shore, Upper and Mid Cape Cod, the northeast part of the state and central Massachusetts.

Public polling in the run-up to election day suggest the race, which appeared fluid at the outset, settled into predictable patterns in the closing weeks.

Democrats, slow to come around to Markey, favored him by wide margins by the end. And women, who strongly favored the Democrat from the outset, only intensified their support.

Gomez consolidated Republican support over the course of the campaign. But with Democrats outnumbering Republicans 3-to-1 in Massachusetts, a statewide GOP candidate needs to build a big lead among independents to pull off an upset.

Gomez, who had a slim edge among independents for much of the campaign, expanded on that edge toward the end of the campaign. But he never built a large enough margin to win.