Which comes first, religion or politics?

On the one hand, political scientists have long held that people’s political choices are formed by their childhood faith, which, for the most part, sticks with them.

On the other, 81 percent of white evangelicals voted for Donald Trump, a thrice-married adulterer who rarely attends church.

A new book by University of Pennsylvania political scientist Michele Margolis argues that it’s political science that has it backward.

As she lays out in “From Politics to the Pews: How Partisanship and the Political Environment Shape Religious Identity,” most Americans choose a political party before choosing the religion to follow in their adulthood — if they choose a religion at all.

“Political science sometimes assumes religiosity is a fixed and stable trait, like gender and race — things we think of for the most part as unchanging,” she said. “But there’s a whole literature out there that says it changes over time.”

The idea upends conventional thinking based on Americans’ lives of 100 years ago, when young people typically got married at age 18 and had their first child at 19. Today, young adults leave home for college. Then they take jobs. They marry later in life and have children even later.

During that transition, Margolis wrote, whatever religion they had fades into the background and they begin to form a political sensibility. Only when they’re ready to settle down and have a family does religion re-enter the picture.

“When it comes time to make religious decisions in adulthood, we have these formed partisan identities,” Margolis said.

Sharpening this political-religious split is the fact that many white Americans who end up as Democrats don’t come back to church, while Republicans tend to become more religious to better align with their political convictions. (She concedes the theory does not apply to African-Americans, who are highly religious and vote solidly for Democrats.)

“It may seem counterintuitive, if not downright implausible, that voting Democrat or Republican could change something as personal as our relationship with God,” Margolis wrote in a recent New York Times op-ed. “But over the course of our lives, political choices tend to come first, religious choices second.”

Margolis’ findings are part of a growing body of evidence about the relationship between faith and politics. In their 2010 book “American Grace,” political scientists Robert Putnam and David Campbell noted the “God gap” — the most religious Americans were Republicans and the least religious were Democrats. The two found that those who say grace before digging into their meals are more likely to find a home in the Republican Party.

Sociologists Michael Hout and Claude Fischer even earlier theorized that the rise in people of no religion — the so-called nones — might be partly due to a backlash against the religious right that may have begun during George W. Bush’s presidency. (Before the 1970s, both parties included similar numbers of religious people.)

“People who think of themselves first as being a Democrat look out at the world and see religious people all tend to be Republican and a particular kind of Republican, and they say: ‘That’s not me. So I must not be religious,’” said Campbell, who teaches at the University of Notre Dame. “So they drop their religious affiliation because of their politics.”

The idea that people form their political opinions first may help explain recent studies showing that white evangelicals no longer frown on elected officials who commit immoral acts in their personal lives.

Famously, a 2016 PRRI/Brookings poll found that 72 percent of white evangelicals said an elected official could behave ethically even if the person has committed transgressions in his or her personal life — a 42-point jump from 2011, when only 30 percent of white evangelicals said the same.

Campbell said the nation’s political divide might foreshadow the emergence of a strong secular coalition. While secular Americans are not nearly as mobilized as white evangelicals, who have an advantage of church organizing, there are signs they may be growing.

In an online post about research he and other scholars published in the June issue of the American Journal of Political Science, Campbell concludes that the movement founded to increase the role of Christianity in the country may in fact be its undoing.