The NYPD wouldn’t hire him — because he is anti-gay, a Police Academy reject complains in a startling new discrimination lawsuit.

The would-be cop from Brooklyn — identified only as “Farhan Doe” — is a Muslim-American who believes homosexuality is a sin as a matter of religious principal, according to the suit.

Doe deserves to be in the NYPD, despite checking the “yes” box next to the question, “Do you believe that homosexuals should be locked up,” in 2009, when he applied, said his lawyer, Jerold Levine.

When Doe — who works as an auxiliary cop in Brooklyn — applied to the Police Academy the next year, he’d softened his views, still believing homosexuality is a sin, but no longer believing gays should be arrested, Levine said.

“They pro forma denied him again — saying he couldn’t possibly be a police officer,” the lawyer said. “The First Amendment is very clear, saying that you can’t discriminate against someone because they have a view you do not like,” he said.

While the NYPD could take action if he acted out in an anti-gay manner, they can’t bar Doe from the force for anti-gay thoughts, the lawyer said.

The NYPD declined to comment.