HARRISBURG, Pa. (AP) – Democrats in Pennsylvania have gone with their party establishment’s choice for a U.S. Senate candidate and rejected an ex-congressman who six years ago nearly won the office.

Katie McGinty, who spent more than a decade as a state and federal environmental policy official, got millions of dollars from the party and its allies to help her side heavily outspend her rivals. She received the endorsements of top Democrats from President Barack Obama on down.

READ MORE: Pennsylvania Great Outdoors Visitors Bureau Hosting Photo Contest With Cash Prizes

KDKA’s Jon Delano breaks down the results:

She defeated second-time candidate Joe Sestak, a retired Navy rear admiral party leaders didn’t consider a team player. John Fetterman, the mayor of an impoverished Pittsburgh-area steel town, finished third. A fourth candidate finished far behind in Tuesday’s voting.

McGinty will challenge Republican incumbent Pat Toomey in the November election. Toomey was unopposed for the Republican nomination.

The fall contest could tilt control of the Senate.

Heather Abraham’s Report:

This is McGinty’s second run for statewide office, after she finished last in a four-way gubernatorial primary in 2014.

McGinty’s side was outspending Sestak’s 2-1 in the late stages of the campaign thanks to more than $4 million in outside support, primarily from the party and from Washington-based Emily’s List, which backs female candidates who support abortion rights.

She was a member of Gov. Tom Wolf’s administration when party leaders recruited her last summer and has close ties to many top Democrats. She had worked for Al Gore, Bill Clinton and former Gov. Ed Rendell.

She beat back sustained criticism from her rivals that she had taken advantage of a revolving door and benefited from energy companies she once regulated.

READ MORE: FDA Announces Recall For Foaming Hand Soap Over Contamination Worries

Sestak, reinforcing his image as a shoe-leather campaigner, walked across the state last year after he formally announced his second candidacy for Senate.

While spurned by the party hierarchy, he was a regular on the local party event circuit around Pennsylvania, and he earned loyalty from rank-and-file activists.

In 2010, Sestak earned the enmity of party leaders by running in the primary and beating party-endorsed candidate Arlen Specter after the longtime Republican U.S. senator switched his registration.

Party leaders complained that Sestak had lost a winnable seat, but his supporters said he had earned another chance to run after doing so well in a strong Republican election year without party leaders’ support.

This year, they were determined again to find a candidate to their liking.

As McGinty leaned heavily on Obama’s support in her campaign ads, running TV and radio ads featuring the president in Philadelphia, Sestak bashed party leaders. He said he was in a fight “for the soul of the Democratic Party.”

Fetterman, the third-term mayor of Braddock, made a splash in his first statewide race. At 6-foot-8, scowling, bald and tattooed, the plainspoken Fetterman touted himself as the most progressive candidate in the race and ran an unconventional campaign, greeting voters in bars, rock music venues and hookah lounges.

Little-known candidate Joe Vodvarka, a semiretired owner of a Pittsburgh-area spring manufacturing shop, had been tossed from the ballot but added back on late in the campaign.

Join The Conversation On The KDKA Facebook Page
Stay Up To Date, Follow KDKA On Twitter

MORE NEWS: Third Stimulus Check: How Could The Economic Relief Package Put More Money In Your Pocket?

(© Copyright 2016 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)