A police veteran with 22 years on the force was told to “tone down” his sexuality if he ever wanted a promotion to lieutenant, according to a discrimination lawsuit.

Sgt. Keith Wildhaber of the St. Louis County Police Department claimed in a lawsuit filed last month that he was passed over for promotion despite “extremely positive feedback” on his work performance and scores in an internal testing process that ranked him third out of 26 candidates during the application period in early 2014.

Then, during a routine patrol checking on local restaurants, Wildhaber claims the owner of Bartolino’s, John Saracino, who was also a member of the St. Louis County Police Board at the time, told him he knew of Wildhaber’s recent application to move up the police ranks.

“Mr. Saracino told [Wildhaber], ‘The command staff has a problem with your sexuality,’” according to the lawsuit filed Jan. 10 in St. Louis County. “If you ever want to see a white shirt, [i.e., get a promotion], you should tone down your gayness.”

Reached Wednesday by the St. Louis Dispatch, Saracino said: “I never had a conversation like that. I would never say anything like that. That’s not me.”

Saracino later resigned from the police board over a letter of support he asked Police Chief Jon Belmar to write to a federal judge who was sentencing his nephew for his involvement in a marijuana ring, the newspaper reported.

Officer Ben Granda, a department spokesman, declined comment, citing an “active lawsuit” in an email on Friday to The Post.

“What we can say is that our main focus in recruiting and developing employees is looking for excellent individuals, no matter what their status, race, religion, sexual preference, political belief, or aspiration is,” Granda said.

Wildhaber, according to the lawsuit, has a clean disciplinary history, “excellent performance reviews” and a strong resume supporting his promotion, but still has not been elevated to the rank of lieutenant.

“Defendant believes that Plaintiff’s behavior, mannerism, and/or appearance do not fit the stereotypical norms of what a ‘male’ should be,” according to the lawsuit, which alleges the department’s gender-based expectations were at least a contributing factor in denying Wildhaber’s promotion.

Wildhaber, according to the lawsuit, joined the St. Louis County Police Department in 1994 after four years in the US Army. In 2011, he was promoted to sergeant after five years assigned to the detective bureau and he was once asked to serve as the department’s liaison to the LGBT community, the Dispatch reports.

Wildhaber’s attorney, Russell Riggan, declined comment when reached Friday by The Post.

“Until the case goes before a jury, we will allow the Petition to speak for itself,” Riggan wrote in an email. “Our system of justice provides the right to a fair trial, and we do not wish to compromise our client’s rights by commenting to the media.”