BROOMFIELD — Jared Polis claimed the Democratic nomination for governor in Colorado with a clear victory Tuesday after he spent $11 million of his own fortune to vanquish three rivals.

The five-term Boulder congressman would become the nation’s first openly gay man elected governor if he wins in November, and his candidacy represents a sharp leftward shift that will test whether Colorado is a true-blue state.

Polis ran a campaign aimed at diehard Democrats with promises to implement all-day pre-school and kindergarten for every child and a single-payer, Medicare-for-all health care system in Colorado – both of which were ballot initiatives rejected by voters in prior elections.

Now Polis faces the tough task of uniting a fractured party even as his liberal image is expected to make it more difficult for Democrats to win moderates and retain the governor’s mansion.

The Associated Press declared Polis the winner at 7:45 p.m. as early results showed him with 43 percent of the vote. Former state Treasurer Cary Kennedy stood a distant second at 26 percent alongside former state Sen. Mike Johnston at 24 percent. Lt. Gov. Donna Lynne remained a distant fourth place at 8 percent.

In Broomfield, where Polis supporters gathered at a hotel for an election night party, the song “Celebration” played as polls closed. And the crowd erupted in cheers when the winner was declared.

From the stage, Polis didn’t waste time and took aim at his Republican opponent in November, Walker Stapleton. “On almost every question before us in this election … Walker Stapleton comes out on the wrong side and the people of Colorado know that,” Polis said, mentioning health care, immigration and honesty.

The Democratic contest finished about where many expected. The latest public poll in the race — released at the start of June when ballots were mailed to voters — showed Polis with a double-digit lead against Kennedy. Johnston and Lynne were struggling to stay in the game at the time. But the poll showed most voters were undecided and the campaigns scrambled to win support in the final weeks.

In Denver, Kennedy supporters gathered at La Rumba to watch the election returns.

Emily Dalgleish, 18, Kate Daley, 20, and Morgan Hess, 20, canvassed for Kennedy and made phone calls for the campaign to the end. “We’ve been knocking on wood all day,” Dalgleish said.

“I slept about 2 hours last night,” Hess added.

In her concession speech, Kennedy thanked her supporters and urged unity in November.

“I know we’re disappointed but we have a lot of work to do ahead of us,” she said. “Together we need to make sure that Walker Stapleton does not become the next governor. We need to elect Jared Polis. We need to grow our Democratic majority in the statehouse and take back the state Senate.”

The early figures show turnout at roughly 27 percent among the 3.8 million eligible Colorado voters.

The interest in the Democratic races exceeded the Republican contests and likewise drew more votes from people not affiliated with either party.

For the first time, unaffiliated voters had the option to cast ballots in either party race under a new ballot initiative approved by voters in the 2016 election to open the party primaries. But turnout remained modest compared to the motivated partisans on either side.

Allyson Bower, a 24-year-old unaffiliated voter who lives in Adams County, cast a ballot Tuesday. She supported Polis because of “his view on universal schooling for the kids — and I know he’s more child-focused than most governors,” she said.

The primary represented the first contested gubernatorial primaries for both parties in two decades and comes after Gov. John Hickenlooper served two terms as a moderate, business-minded Democrat.

The Democratic contest drew a half-dozen candidates but only four survived to make the ballot. Polis entered the early front-runner given his high profile from 18 years in the public spotlight dating back to his 2000 campaign for a state board of education seat and his more recent role as the antagonist to the state’s expanding oil and gas industry.

The 43-year-old technology entrepreneur — who is one of the richest members of Congress — only accepted donations of $100 or less and self-funded the remainder of his campaign.

He encountered early resistance from environmental activists who worried that Polis had shifted to more moderate positions and the teachers unions who backed Kennedy.

But he offered a number of proposals to appeal to the party’s stalwarts, whether the single-payer health care plan or a pledge to push the state to 100 percent renewable energy by 2040.

Kennedy, 50, made education her top focus with a pledge to spend more money on education and boost teacher pay — moves that drew the endorsement of the Colorado Education Association, the state’s largest teachers organization. The group’s political arm spent about $2 million to help boost her campaign and criticize her rivals.

The issue of education became a defining one in the race, and it influenced the vote of Sean Grieser, a 53-year-old Denver Democrat. Grieser said he voted for Polis despite his preference for Kennedy’s education plan.

“I voted for Polis because I liked his overall plan,” he said outside a polling location in Denver. “Kennedy had a fantastic plan for education, but (all the candidates) are all so similar on education. I liked Polis’ plan on the other issues.”

Johnston, a 43-year-old former teacher, drew support from organizations and donors aligned with Democrats for Education Reform, a group that supports expanding charter schools. But he focused much of his campaign on gun violence, criticizing Polis’ record on the issue and touting his support for universal background checks and ammunition magazine limits.

A super PAC-styled political committee called Frontier Fairness spent more than $5 million to help boost Johnston, accepting $2 million in donations from former New York City Mayor Michael Bloomberg, but it didn’t make the difference.

Lt. Gov. Donna Lynne lagged behind the pack. Her campaign made the case she is the most qualified for the job given that she has served as Hickenlooper’s No. 2 since May 2016. Lynne, 64, even had “Fight for Colorado” permanently tattooed on her arm for a campaign commercial.

Staff writer Chaney Skilling contributed to this report.