A white professor claims a black student ended his CUNY career by falsely branding him a racist after he criticized a student’s homework.

Political science instructor John Trujillo says he never even got a chance to defend himself against the student’s claims as the Borough of Manhattan Community College moved to fire him.

“They just threw me away like a piece of trash,” he told The Post.

Trujillo is now suing the school, claiming reverse racial discrimination. He was treated “differently from and less favorably than . . . employees who were not white,” according to court papers filed in Manhattan federal court.

The trouble began in October 2014 when the adjunct professor disciplined a black student who failed to follow homework directions, he says in a $3 million legal filing.

He’d asked students to turn in their work on a 4×6 index card, but the student used a 3×5 card instead, prompting an exchange in which she called Trujillo a “d–k” in front of the class, the teacher claims.

After a second run-in with the disrespectful student, Trujillo, 51, had security escort the girl out.

A different student, who had not heard the earlier exchange between the teacher and his unruly charge, “stood up in protest of her classmate’s removal by security, and decided to leave the classroom herself,” according to court papers.

“She said, ‘I’m going to write a letter, I’m going to take you down,’ ” Trujillo says.

The student, who was also black, charged Trujillo was a racist who told his class that all black people were on welfare and that he should be teaching at an Ivy League school.

“She twisted things I said,” Trujillo claims, saying he’s challenged students who voice racial stereotypes.

‘They just threw me away like a piece of trash…I never got the sense that they cared to get to the truth’ - John Trujillo

Trujillo’s prior classroom evaluations had been so positive, administrators had stopped conducting them, he said. But after the complaint, they revisited his class and rated his teaching “unsatisfactory.”

As the professor spent weeks challenging the negative rating, a chorus of other student complaints emerged. BMCC escorted Trujillo from his classroom and fired him in February 2015 from his $21,000-a-year post.

One black student in Trujillo’s class wanted to defend the teacher against fellow classmates who were “making up lies.” But administrators never talked to this student, according to Trujillo’s lawyer, Marshall Bellovin.

He “didn’t get a fair and impartial investigation and accounting of the facts,” Bellovin said. “It was open and shut apparently from the start.”

Trujillo wants a chance to tell his side of the story.

“I never got the sense that they cared to get to the truth,” he said.

Prejudicial treatment is “wrong when a white person does it to a black person, it’s wrong when anyone of any race does it to anyone,” he added.

BMCC didn’t return a message seeking comment.