This map shows how Biden won back Pennsylvania in the 2020 election

Key Points
  • Joe Biden won back Pennsylvania for Democrats in the 2020 election after President Donald Trump carried the state in 2016.
  • To do so, he improved upon Clinton's margins in a range of both blue and red counties.
  • He particularly outperformed Clinton in the counties surrounding Philadelphia.
U.S. Democratic presidential candidate Joe Biden gestures as he speaks during a drive-in campaign event at Bucks County Community College in Bristol, Pennsylvania, October 24, 2020.
Kevin Lamarque | Reuters

Joe Biden's birth state delivered.

To win back Pennsylvania for Democrats in the 2020 presidential election, the president-elect had to improve upon Hillary Clinton's 2016 performance across wide swaths of the state.

Biden will beat President Donald Trump in the Keystone State after the Republican incumbent carried Pennsylvania four years ago, according to NBC News. The former vice president leads his GOP opponent by more than 45,000 votes with some ballots outstanding. Trump won Pennsylvania by a similar margin of about 44,000 votes in 2016.

Here are the voter demographics for the 2020 presidential election
Demographics for the 2020 U.S. election

To cause the swing, Scranton native Biden beat Clinton's margins of victory in a range of both blue and red areas. The eastern part of the state, in particular, appeared to propel Biden's success. Pennsylvania's 20 electoral votes put Biden above the threshold to become president-elect when NBC News projected his victory on Saturday.

The maps below show the county-level win margins for the candidates in 2016 and 2020. This year's results could still shift as Pennsylvania tallies final ballots.

To start, Biden leads in two of three often discussed counties that supported President Barack Obama twice before flipping to Trump in 2016. He holds an advantage in both Erie County in the northwest corner of the state and Northampton County on its eastern border.

He came nowhere close to winning back Luzerne County, an area in northeast Pennsylvania that saw a more than 20 percentage point swing toward the GOP in 2016. Even so, Trump won the area by about 15 percentage points in 2020, down from 19 percentage points four years ago.

Eastern Pennsylvania played a huge role in propelling Biden to the White House. He won the Democratic stronghold of Philadelphia County, home to the country's sixth-most populous city, by about 63 percentage points or more than 440,000 votes. The figures could move more in Biden's favor as Philadelphia counts its final ballots.

Still, Trump has so far fared better there than he did in 2016. Clinton carried the county by 67 percentage points.

Biden significantly improved upon Clinton's margins in the areas surrounding Philadelphia. He won Delaware County by about 26 percentage points, after his predecessor as the Democratic nominee carried it by 22 points.

In Montgomery County, his 26 percentage point advantage beat out Clinton's 21-point edge. Biden also carried Chester County by about 17 percentage points, compared with the former secretary of state's roughly 10 percentage point margin of victory.

Further north, Biden won Lackawanna County by more than 8 percentage points. Clinton carried the area, which includes the president-elect's hometown of Scranton, by about 3 points.

It wasn't just eastern Pennsylvania that boosted Biden. He improved upon Clinton's margins in the blue counties of Dauphin, where the state capital of Harrisburg sits, and Centre County, which includes Penn State University.

He also saw a bump in support in western Pennsylvania. Allegheny County, home to the state's second-most populous city, Pittsburgh, backed Biden by about 20 percentage points. Clinton won the area by roughly 17 percentage points in 2016.

Biden even cut into Trump's margins in the red areas surrounding Pittsburgh. Even though the incumbent overwhelmingly won the counties of Washington, Westmoreland, Butler and Beaver, his margin of victory dropped by at least a percentage point in all of those areas compared with 2016.

The trend carried across a range of conservative counties in the state, where Biden performed at least slightly better than Clinton did four years ago.

One factor at play is a smaller third-party presence in Pennsylvania. Libertarian Jo Jorgensen won 1.1% of the 2020 vote, while Green Party candidate Howie Hawkins did not make the presidential ballot.

Four years ago, Libertarian Gary Johnson and Green Party candidate Jill Stein combined to win more than 3% of Pennsylvania votes.

Subscribe to CNBC on YouTube.