There’s nothing like a national election to illuminate the complex and slippery nature of bias at work in the country today. Just ask Pete Buttigieg. Always something of an underdog in the Democratic primary, Buttigieg has started to poll well in Iowa and New Hampshire relative to his national numbers and has proved to be a formidable fundraiser. But as his profile has risen, murmurs about how his sexual orientation might affect his bid have gotten louder and louder.

There are plenty of reasons, of course, why Buttigieg might struggle to gain traction among more voters. His lack of statewide or national political experience is one potential stumbling block. Voters of all races may also balk because he has faced criticism for his handling of the predominantly white police force in South Bend, where a white officer recently shot and killed a black man, and for implementing economic policies that some feel ignore or harm communities of color. And another scapegoat has emerged: Last month, a leaked memo described the results of a focus group conducted by Buttigieg’s own campaign in July, which found that some black voters in South Carolina were uncomfortable with his sexual orientation.

It’s hard to know how much that discomfort truly matters — even a number of the skeptical focus group voters were still open to supporting Buttigieg — and to the extent that it exists, it’s certainly not confined to one group. But regardless of the reasons behind his depressed support, Buttigieg’s candidacy is a case study in the dilemma facing gay and lesbian candidates running at all levels of office today. It’s remarkable, in one sense, how little Buttigieg’s sexual orientation has come up in the primary so far, considering that only 10 years ago, the election of a lesbian woman as Houston’s mayor was enough to make national headlines. Voters’ willingness to support gay and lesbian candidates is at an all-time high, and multiple studies by political scientists have suggested that Democrats are especially unlikely to discriminate against candidates like Buttigieg. “If anything, there are some subgroups of Democrats who would be more likely to vote for a gay candidate,” said Gabriele Magni, a political science professor at Loyola Marymount University.

Stop there, and you’d have a pretty rosy electoral prognosis for Buttigieg — focus group skepticism notwithstanding. But it also isn’t the full story. Some Democrats haven’t moved as quickly to the left as others on gay rights issues. And a substantial chunk of Republicans are still comfortable saying they wouldn’t support a gay candidate. As ever, it’s difficult to know what actually keeps a voter for pulling the lever for a particular candidate, but Buttigieg’s sexuality could be a sticking point for some. Experts like Magni said Buttigieg might find it tough to draw support from the most conservative or religious corners of the Democratic primary electorate, not to mention Republicans in the general election. And in a primary driven by voters’ concerns about how electable the candidates are, the perception that a significant slice of voters would never support a gay candidate might be an even bigger hurdle than the reluctant voters themselves.

Just a few election cycles ago, a debate about the electoral impact of a gay candidate’s sexual orientation would have had a clear answer — because being gay was a dealbreaker for almost half the country. As recently as 2007, only 55 percent of Americans said they would vote for a gay or lesbian candidate for president, which is only slightly higher than the share who currently say they would vote for a socialist. But many voters’ qualms about the prospect of a gay or lesbian president evaporated over the following decade, and 76 percent of Americans — including a majority of Republicans — now say they wouldn’t have a problem supporting a gay candidate for president. That’s still not the near-uniform level of hypothetical support the same polls show for a female or black candidate, but it’s also not obviously disqualifying. After all, only 63 percent of Americans say they’d vote for a candidate over the age of 70, which describes the three top-polling candidates in the Democratic primary.

There are plenty of signs, too, that a Democratic primary is particularly friendly terrain for a gay candidate. Political scientists have found in studies and interviews with candidates that gay and lesbian candidates overwhelmingly run as Democrats, in part because Democratic voters don’t seem to penalize candidates for their sexual orientation. A recent experimental study co-authored by Magni found that voters who identify as very liberal and nonreligious were more likely to support a gay candidate over a straight candidate.

The impulse to size up the electoral landscape and run where their support is strongest can partially help explain why gay and lesbian candidates often don’t find their sexuality to be a serious barrier. “When you talk to gay and lesbian candidates, they’ll generally tell you their sexual orientation didn’t matter much in their race, and that’s in part a function of the fact that they tend to run in more liberal areas, like cities,” said Donald Haider-Markel, a political science professor at the University of Kansas and the author of “Out and Running: Gay and Lesbian Candidates, Elections, and Policy Representation.”

But there are still pockets of the Democratic electorate where voters’ views of gay people aren’t as liberal. And that poses a few potential problems for Buttigieg, who has to run a national campaign. A significant chunk of his base is composed of white college-educated Democrats; this is also a subset of voters where his sexual orientation is highly unlikely to be a roadblock, given that several decades of data from the General Social Survey shows that people in this group are especially likely to say that homosexual relationships are never wrong.

But as my colleague Nathaniel Rakich wrote recently, Buttigieg has some fierce competition from Elizabeth Warren for white college-educated voters. And while the groups with whom he might be hoping to expand his support — like religious voters or whites with lower levels of education — are certainly not uniformly opposed to gay candidates, they are groups where his sexual orientation might be more of an issue. People who attend church frequently are much less likely than non-churchgoers to believe same-sex marriage should be legal, according to the Pew Research Center. Likewise, lower levels of education tend to come with lower levels of support for gay marriage.

Voters’ feelings about gay candidates could show up in more nuanced ways as well. The specter of electability, for example, could turn out to be a bigger roadblock for Buttigieg than outright hostility toward gay people. For instance, a recent Politico/Morning Consult poll found that voters were basically split on whether the country was ready for a gay or lesbian president, and only 26 percent said that their neighbors were ready.

To be clear, several experts told me these electability concerns don’t have a lot of evidence to support them, although that may be partially because there hasn’t been a lot of research on how gay candidates perform in real-life elections, and candidates may also avoid contests — like Republican primaries — where they’re all but destined to lose. But discomfort with gay marriage or homosexual relationships won’t necessarily stop voters from ultimately supporting a gay candidate. And Haider-Markel pointed out that the people with the strongest prejudices against gay people are also highly unlikely to vote for any Democrat, which means that in a general election, Buttigieg’s sexuality would probably matter less than the “D” next to his name. Dislodging gut-level intuitions about electability can be tricky business for a candidate, though. That’s particularly true when significant chunks of the electorate — including almost 40 percent of Republicans — are still perfectly comfortable telling a pollster they wouldn’t vote for a gay candidate. It’s hard not to assume that a neighbor’s stubborn opposition to gay marriage will shape their vote in some way — even though in reality, the forces that influence our choice of candidate are far more complex.

This complexity makes it nearly impossible to say for certain whether it’s Buttigieg’s sexual orientation — rather than his age, or his political inexperience, or his policy positions, or some ineffable combination of factors — that has kept him from rising further in the polls. And that will also make it hard to assess, when all the ballots are cast and the Democratic nominee is chosen, just how much Buttigieg’s electoral chances were affected by his sexuality.

But it also means that even if some voters are being held back by Buttigieg’s sexual orientation now, other parts of his biography, like his military service or Christian faith, could still change the way they think about him. The good news for Buttigieg is that there are months to go before the primaries begin, and he has plenty of cash to spend on introducing himself to voters who might currently know next to nothing about him. “At a very basic level, Buttigieg could reduce some bias just by getting voters to see him as a gay man who was also in Afghanistan and goes to church on Sunday,” Magni said. “Sexual orientation is less likely to play a role in vote choice when people move past the stereotypes they have in their mind about who gay people are supposed to be.”