The 2020 election produced a record number of people voting and the highest percentage turnout in more than a century. It was an election that cost Donald Trump a second term in the White House and handed the Oval Office to Joe Biden. What changed from 2016 to 2020?

The Pew Research Center has provided multiple answers to that question, based on a survey of more than 11,000 Americans who said they had cast ballots and who were subsequently verified through other records as having voted.

More than 158 million Americans voted in the presidential election, which translated to 66 percent of those eligible. Despite the coronavirus pandemic, turnout increased over 2016, in part because of what was at stake in the competition between Biden and Trump and because many states made it easier for people to cast ballots by mail or to vote in person before Election Day.

Biden won the popular vote 51 percent to 47 percent. Most 2020 voters, around 6 in 10, also had voted in both the 2016 presidential race and in the 2018 midterm elections. That group split 53 percent to 46 percent for Biden. Those who voted in 2016 but not 2018, amounting to 13 percent of the electorate, backed Trump 53 percent to 45 percent. Those who voted in 2018 but not 2016, just 6 percent of the electorate, went most heavily for Biden, 62 percent to 36 percent.

Then there were people who had not voted in either 2016 or 2018. They made up almost 20 percent of the electorate, and they went narrowly for Biden, 49 to 47. Trump’s campaign had hoped to win the election by motivating people sympathetic to him who had not voted in 2016. The findings in the Pew survey show that Trump was able to bring out many of those targeted supporters, and he did better than some pre-election polls had suggested he might do. But the survey highlights that Biden and the Democrats were also able to draw many new people into the electorate.

Biden’s popular-vote margin of 7 million votes was larger than Hillary Clinton’s margin of nearly 3 million votes in 2016. His electoral-college majority — 306 to 232 — was identical to Trump’s initial margin in 2016. (Because of “faithless electors,” the final official tally in 2016 turned out to be 304 to 227.)

Clinton could have won the presidency in 2016 if approximately 78,000 votes had switched in Wisconsin, Michigan and Pennsylvania. Trump could have won in 2020 if approximately 65,000 votes had shifted in Wisconsin, Georgia, Arizona and Nebraska’s 2nd Congressional District. Trump continues to make baseless claims about the election being rigged.

Biden won by moving some of the parts of the electorate in his direction. One major shift, according to Pew, was among independents, a move foreshadowed in the 2018 election, when independent voters helped fuel a midterm surge that put Democrats in control of the House. Pew’s figures show Trump winning independents by a single point in 2016. In 2018, Democrats won them by 15 points. Biden then won them by nine points.

The battle for suburban voters, long the key geographic battleground in presidential elections, went decisively for Biden, by Pew’s findings. Trump won them by two points in 2016. Biden carried them by 11 points in 2020. Trump increased his share of the rural vote, but while Biden easily won voters in urban areas, his margin was smaller by double digits than Clinton’s. Taken together, more than half of Biden’s vote — 55 percent — came from the suburbs, compared with 48 percent for Clinton in 2016.

Biden did better than Clinton among moderate-to-conservative Democrats and liberal Democrats (including in both cases the votes of Democratic-leaning independents). Trump increased his support among conservative Republicans and leaners compared with 2016 but did worse among moderate and liberal Republicans and leaners.

Trump won White men without college degrees by 35 points in 2020, but that was a decline from his 50-point margin among them in 2016. Biden, in the meantime, got increased support from White men with college degrees compared with Clinton, who battled sexism throughout her unsuccessful campaign.

Another closely watched group in 2020 was White women without college degrees. Some Democrats were hoping that Trump’s personal behavior would result in some defection to Biden. Instead, Trump’s margin grew from 23 points in 2016 to 29 points in 2020.

Overall, with Biden gaining among men and Trump making some gains among women, the gender gap narrowed between 2016 and 2020.

Biden, like Clinton, dominated among Black voters, who remained the most loyal core of the Democratic coalition. But there were generational differences. Trump won just 4 percent of Black voters 50 and older but drew 12 percent among those under 50.

Biden also won Hispanic voters, but his margin tumbled in comparison with support for Clinton in 2016 and for Democrats in the 2018 midterms. In 2016, Clinton won Hispanics by 38 points, and Democrats collectively won them by 47 points in 2018. Biden, however, carried them by 21 points, according to Pew’s findings. Biden did far less well among Hispanic voters without college degrees than those with degrees.

The generations took divergent paths, with voters under 50 backing Biden and those 50 and older supporting Trump. But Biden’s support among those younger voters was notably stronger than Trump’s was among older voters. Pew also noted that 2020 marked the first time that baby boomers and the “silent” generation that immediately preceded them made up less than half of the electorate, falling from 52 percent in 2016 to 44 percent last year.

Protestant voters backed Trump, Catholic voters split almost evenly between the two candidates, and religiously unaffiliated voters went for Biden. The religiously unaffiliated voters made up a larger share of the electorate than did White evangelicals and backed Biden by a margin of 45 points. White evangelicals went for Trump by 69 points.

There were stark differences across denominations based on church attendance: Those who said they attend church monthly or more often backed Trump by 19 points. Those who said they attend less often than that went for Biden by 18 points.

Changes in voting procedures prompted by the pandemic produced a record number of absentee and mail ballots, dwarfing both the percentage of people who cast in-person votes before Election Day as well as those who voted on Election Day. And more than 4 in 10 who voted by mail or absentee said they had never done so before.

Trump won Election Day voters 65 percent to 33 percent and came out ahead among those who cast in-person early votes, 52 percent to 47 percent. But among the nearly half of the electorate that cast mail or absentee ballots, Biden won 65 percent to 33 percent.

With more than 158 million people voting, that still left tens of millions of eligible voters on the sidelines. The Pew study examined who they were how they might have voted, had they chosen to do so. More than 8 in 10 nonvoters did not have college degrees, compared with about 6 in 10 among those who did vote. More than 6 in 10 nonvoters have incomes below $50,000, compared with 35 percent of voters.

Pew found that nonvoters preferred Biden by 15 points — 50 percent to 35 percent. That marks a big shift from 2016, when those nonvoters preferred Clinton over Trump by half that margin. Had all these nonvoters turned out in November, Biden would have won by an even bigger margin.