After capturing Maryland’s Democratic primary by an overwhelming margin, Lt. Gov. Anthony Brown seemed almost certain to become the next governor in a state where Democrats outnumber Republicans by a 2-to-1 margin.

But Brown’s greatest strength in the primary — his two terms as Gov. Martin O’Malley’s understudy — became his albatross against Republican Larry Hogan, whose commanding victory Tuesday stunned Maryland’s Democratic establishment.

President Obama’s endorsement — along with appearances by first lady Michelle Obama and Bill and Hillary Clinton — could not save him from defeat.

Hammering Brown over O’Malley’s tax increases, Hogan unleashed a roiling undercurrent of voter discontent that flared not only in Maryland, but also against Obama and Democratic incumbents across the country.

At the same time, O’Malley — Brown’s political benefactor, the one who chose him as his successor — was growing increasingly unpopular as his reign as governor entered its final months.

Hogan’s path to the Md. governor’s office

Where Brown needed large turnout — Baltimore and Prince George’s County — too many voters stayed home. And where he expected big numbers — Howard County, home of his running mate Ken Ulman — Hogan won by more than 5,000 votes.

“Hogan smartly found the most emotionally potent campaign issue — economic uncertainty and high taxes — and drove it home incessantly and persuasively,” said Keith Haller, a pollster and strategist in Maryland.

“It allowed his campaign to seize the overall election message,” Haller said, “and created a sharp, distinguishing contrast with Brown.”

Brown’s advantages even before the start of the general election against Hogan included a double-digit lead in polls. He inherited O’Malley’s robust and experienced campaign organization, as well as the governor’s vast fundraising machine.

As an African American, Brown’s campaign could count on voters in two of Maryland’s most populated locales — Baltimore and Prince George’s County — being energized by the possibility of electing the state’s first black governor.

But Brown’s message evolved into a barrage of attacks that his campaign unleashed on Hogan. At the same time, polls suggested that nearly a third of all voters did not have a clear impression of Brown, a military veteran who attended Harvard Law School and served in the General Assembly before O’Malley tapped him as lieutenant governor in 2006.

During debates and on the campaign trail, Brown came off as a polished, tightly scripted candidate. Hogan, with his thick neck and unstylish business suits, was more the everyman.

“Republicans, independents and more than a few Democrats were looking for a change in direction, and Brown never provided that sense that he was the change,” said Mike Morrill, a Democratic strategist in Maryland. “He never created the Brown vision for the state.”

“He made the major front-runner's mistake, trying to protect his lead instead of building his lead,” Morrill said. “As his lead eroded, he ran a negative campaign. He was trying to stop the erosion rather than giving people a reason to vote for him.”

While Hogan mined a singular economic message, Brown’s identity remained a blur, as he struggled to strike a balance between having served as O’Malley’s second-in-command and forging his own brand.

His candidacy lacked a “core, distinguishing rationale,” Haller said. “What was Brown’s signature issue? Most voters were left head scratching.”

Hogan’s victory is not the first for a Republican gubernatorial candidate in Maryland. Spiro Agnew, then Baltimore county executive, became governor in 1966 before Richard Nixon chose him as his running mate. In 2002, Robert Ehrlich defeated Kathleen Kennedy Townsend by nearly four percentage points, overcoming the edge she had as then-Gov. Parris Glendening’s lieutenant governor.

But the 2002 race was not shaped by broader national currents. Townsend, a weak candidate, was crippled by a “horrible” campaign organization, said Donald Norris, a public policy professor at the University of Maryland Baltimore County. “A good Democrat would have beaten Bob Ehrlich.”

In the current campaign cycle, Norris said, “it’s a Republican year, nationwide,” with GOP candidates benefitting from voter anxiety and dissatisfaction with Obama over immigration and the rollout of the Affordable Care Act, among other issues.

“The Democratic electorate was depressed and the Republicans smelled blood and went for it,” said Maryland state Sen. Jamie Raskin (D-Montgomery). “The political mood has been defined at the national level; there’s been a sense of despondency and drift.”

In the Democratic primary, one of Brown’s main opponents, Attorney General Douglas F. Gansler, accused him of lacking the experience or vision to take over Maryland’s state government.

Yet, Brown cruised to his party’s nomination in June, positioning himself as an extension of O’Malley as he defeated Gansler and state Del. Heather R. Mizeur by a more than 2-to-1 margin.

The electorate he faced in the general election — a mix of Republicans, independents and Democrats — was more conservative than primary voters, and far less likely to embrace O’Malley, who pushed a series of progressive causes such as death penalty repeal and marriage equality.

But it was the governor’s tax policies which likely pushed broad swaths of white Baltimore County voters over to Hogan. “I was out there knocking on doors and you could go 10 blocks without seeing a Brown sign,” Raskin said. “The bottom fell out among white voters in Baltimore County.”

Instead of countering Hogan’s critique of the economy with his own plan, Brown resorted to an onslaught of television ads that sought to portray the Republican as extreme on social issues.

“People wanted a strong economic development message and vision and I don’t think they got it from Brown,” said Albert Wynn, the former congressman whose district included Prince George’s and Montgomery counties. “People wanted to know, where are we going?”

As the campaign ended, Brown needed an outsize turnout from African American precincts to win. His failure to draw enough support from blacks in Baltimore and Prince George’s County may have been the result of what also hurt him with white voters.

“A bland campaign,” said Matthew Crenson, a retired political science professor at Johns Hopkins University. “Brown tried to get the endorsement of every incumbent Democrat in the state, which made him a consensus candidate and prevented him from saying anything controversial.”

Where Brown became more daring, Crenson said, voters may have seen him as untrustworthy.

His repeated portrayals of Hogan as anti-women were challenged by the Republican himself. At one point, Hogan’s daughter appeared in a television ad to defend her father.

“Hogan was able to show Brown as someone who was distorting his positions,” Crenson said. “In that way, he may have overdone it.”