Maryland’s next governor is Wes Moore, a 44-year-old first-time candidate who coasted to an easy victory on Tuesday, riding a message of optimism and a promise to expand opportunities for all.

Moore, a Democrat, shatters a longstanding racial barrier in Maryland politics: He will be the state’s first Black governor.

Maryland has had 30 governors since the current method of electing governors by statewide popular vote was established in 1867. Every single one of them has been a white man.

“It’s not lost on me that I’ve made a little history here tonight myself,” Moore said to cheering supporters at hotel in Baltimore’s Harbor East neighborhood. “This is more proof that progress is not inevitable, but progress is possible in the state of Maryland,” Moore said.

The Baltimore Banner thanks its sponsors. Become one.

See Maryland election results

Moore defeated Republican Dan Cox, 48, an ally of President Donald J. Trump who failed to gain traction among the Democratic and unaffiliated voters who make up the majority of Maryland’s electorate. There were also three third-party candidates on the ballot.

The Associated Press called the race in Moore’s favor as soon as polls closed at 8 p.m.

The Baltimore Banner thanks its sponsors. Become one.

Election results for governor

The emcee played “Celebration” by Kool & the Gang and said that Maryland is making history.

It will take another week and a half to count all of the ballots that were cast in Maryland. Ahead of the Election Day, three different independent polls showed Moore with secure, double-digit margins over Cox, making it clear that he was likely to win.

Outgoing Gov. Larry Hogan, a Republican, posted on Twitter that he’d spoken with Moore by phone and congratulated him.

“Our team is committed to ensuring a smooth and orderly transition to the next administration, and I look forward to meeting with the governor-elect in the coming days,” Hogan wrote.

Moore’s supporters were in high spirits at his party, snapping selfies, sipping wine and soaking in the moment. A parade of Democrats took the stage to give speeches about the party’s victories on Tuesday.

The Baltimore Banner thanks its sponsors. Become one.

At a Democratic party in Towson, former Baltimore County Councilman John Olszewski Sr. briefly cut the music to announce the governor’s race was called in Moore’s favor — the room erupted into applause.

Earlier in the day, Baltimore County Executive Johnny Olszewski Jr., the retired councilman’s son, said Moore “is going to transform what we [Baltimore County] can do in the years ahead.”

Cox, meanwhile, organized an optimistically titled “victory party” at an Annapolis hotel for Tuesday night.

When Cox took the stage hours after the Associated Press had projected Moore had won, he did not concede. Instead, he spurned “predetermined statements” made by the media and said it was “very possible” that he could still win once all votes were counted.

”No matter the outcome there is no doubt that you made history,” Cox told the crowd .

The Baltimore Banner thanks its sponsors. Become one.

Jim Pelura, a veterinarian and former Maryland Republican Party chairman, said he was disappointed with the position the party has taken on Cox. He called on Republicans to stick with the “Republican philosophy” and remain united.

While Cox lost the election, he still has a large following, Pelura said. “I don’t think Dan will be going anywhere.”

The Baltimore Banner thanks its sponsors. Become one.

For many Maryland voters, the choice between Moore and Cox was an easy one.

Moore, though lacking political experience, boasted a resume that includes being a Rhodes scholar, writing a best-selling book, serving with the U.S. Army in Afghanistan, founding an education company and leading a large nonprofit foundation. His campaign slogan was “Leave No One Behind,” borrowed from the military, and he promised to work on ending economic and educational disparities.

Cox, an attorney who has served one term in the House of Delegates, offered a bleak picture of Maryland that he said he was equipped to fix — a state with educators “indoctrinating” students about gender and sexuality, with rampant crime in Baltimore, with the government exerting too much control on individual decisions.

Cox lacked the financial ability to broadcast his message to a wide audience of voters and did not have the backing from many leaders in his own party — including Hogan, who called Cox a “QAnon whackjob” who is unfit to govern. Cox’s most notable endorsement came from Trump, who did not come to Maryland or otherwise actively campaign for Cox.

Cox spent a considerable amount of time and money this fall on an unsuccessful legal challenge to how mail ballots are counted. Under repeated questioning from reporters over the course of the campaign, Cox would not commit to respecting the results of the election, saying he wanted to see what those results would be first.

Moore, meanwhile, blanketed the airwaves with positive ads and lined up support from President Joe Biden, Vice President Kamala Harris, former President Barack Obama and former Secretary of State and 2016 presidential nominee Hillary Rodham Clinton. He lined up support from unions representing teachers, police officers and state government workers.

“Voting for Maryland’s first Black governor feels absolutely terrific,” said Ralph LaRue Smith, 62, who cast his ballot at the central Enoch Pratt Free Library in Baltimore.

Smith said he believes Moore will help Maryland reach “the next level” in terms of smart use of state resources and innovative policies.

“People need to get out today and exercise their rights, especially young people, because if not, we’ll have a difficult road ahead,” Smith said

Bessie Gray, 87, voted early Tuesday morning in Baltimore for Democrats up and down the ballot because she said the party is the only one left fighting for democracy.

Gray said she used to think of white, male, Republican politicians as polite and well-educated. But that changed with Trump, who she described as “real loud and not classy.” Cox is just like him, she said.

”Trump was the beginning of something I had never seen before,” Gray said. “Gentlemen shake each other’s hands when it’s all over. Can you imagine not giving over the title? Where am I? Another planet? Is this earth? Cox is the same way. He wants to tear everything down.”

George Leap, 76, voted for Cox at Digital Harbor High School in Baltimore, though he said he’s supported Democrats in the past.

Leap said the health of the economy is one of his top issues and he thinks electing more Republicans in Maryland and nationally will help stabilize it.

”I’m a big proponent of the existing Gov. Larry Hogan. He wasn’t too far left or too far right,” Leap said. “And if Cox wins, I hope he’ll govern the same way.” He noted, however, that Hogan declined to endorse Cox.

Maryland Democratic Party Chairwoman Yvette Lewis said that the diversity of the ticket should be a model for the rest of the nation.

Not only will Moore be the state’s first Black governor, but his running mate Aruna Miller will be the first immigrant and woman of color as lieutenant governor.

“I’m proud to be a Democrat, I’m especially proud to be a Maryland Democrat. I’m especially proud to be a Wes Moore Maryland Democrat,” Lewis said in an interview. “Our ticket is amazing. And one of the things we are showing is how to embrace diversity. We’re going to be a template for the nation, and I’m very proud of that.”

Baltimore Banner reporter Jessica Calefati, Taylor DeVille and Clara Longo de Freitas contributed to this article.