Suppose you’re the sort of liberal who thinks America should accept and celebrate diverse peoples, traditions, and cultures. But you also believe gays and lesbians should enjoy the rights of other humans, including the right to marry.

Or let’s say you’re the type of conservative who, like Donald Trump, thinks we should close our doors to Muslims. But you also think gays are sinful, and that marriage should be reserved for straights.

Either way, the Orlando tragedy poses a big problem for you. When Omar Mateen killed 49 people at a gay nightclub, he reminded us that some cultural groups in the world simply don’t accept homosexuality.

And the haters come in all colors and faiths, of course. Anti-gay white conservatives who want to keep out members of the Islamic faith might be surprised — and, I hope, embarrassed — about how many Muslims share their view of gays. How can you condemn homosexuality, then demand the exclusion of people who do the same?

Muslims are hardly united in their attitudes about gays. According to a 2015 survey by the Public Religion Research Institute, 42 percent of American Muslims favor same-sex marriage. That’s less than Jews (77 percent) and Catholics (60 percent), but more than white evangelical Protestants (28 percent).

And Muslim-American leaders were quick to condemn Mateen, who declared his allegiance to the Islamic State before his rampage. “You are an aberration,” a spokesman for the Council on American-Islamic Relations said, referring to ISIS. “They don’t speak for our faith.”

advertisement | advertise on newsday

Not quite. A Turkish newspaper aligned with President Recep Tayyip Erdogan called gays “perverted” in a headline reporting on the Orlando attack. And the Al Jazeera Arabic Facebook page featured hundreds of comments praising Mateen and condemning his victims, whom one poster called “homosexuals filth.”

Worldwide, majority-Muslim countries are overwhelmingly anti-gay. In a 2013 Pew Charitable Trust study, 97 percent of Jordanians said homosexuality should not be “accepted by society”; in Egypt, 95 percent agreed; in Tunisia, it was 94 percent.

So we also need to make an effort to assimilate Muslim newcomers and their families to American values, including the equal worth of sexual minorities. The son of Afghan immigrants, Mateen went to American schools and worked for American companies. But we failed to teach him about the fundamental humanity of his gay fellow citizens.

Of course, the wish to bar all Muslims from our country reflects its own failure of American civic education. It’s every bit as odious as the rejection of gays.

How many GOP leaders who denounced Mateen have engaged in their own brand of anti-gay bigotry, blocking same-sex marriage or even anti-discrimination measures? In Florida, it is legal to deny someone a job or an apartment because of his or her perceived homosexuality. That’s a form of hatred, too.

Sign up for The Point

Go inside New York politics.

I can hear their reply: We reject measures for gay rights, but unlike the Sacramento minister who said Christians “shouldn’t be mourning the death of 50 sodomites,” we don’t wish harm on gays. That sounds like white Southerners who denounced lynching but also opposed civil rights for African-Americans.

When someone comes here from another nation, we have to teach him or her that religion and culture are not legitimate grounds for bigotry and hatred. Diversity is a hugely important value, but we can never let it trump civility.

And when home-grown bigots demand the exclusion of a religious group, we need to remind them about all of the diversities within such categories. All Muslims aren’t homophobes, any more than all Muslims are terrorists. And to the degree that they disdain gays, they have more in common with white conservatives than most of us have recognized. Until now.

Jonathan Zimmerman teaches education and history at New York University. He is the author of the upcoming “Campus Politics: What Everyone Needs to Know.”