The Hershey Co. falsely told its 52-year-old senior counsel for global intellectual property that his job was eliminated, a new lawsuit alleges.

Kurt Ehresman, who is white, learned about three months later that Hershey hired a black, female lawyer under 40 into the same position, the complaint, filed Feb. 6 with the U.S. District Court for the Western District of Pennsylvania, says. Unlike Ehresman, she was only a trademark attorney, not a licensed registered patent lawyer, the lawsuit says.

The move came roughly five years after Hershey recruited him to be “the first licensed practice attorney” in the candymaker’s more than 100-year history, Ehresman charges in the complaint . And it required him to give up his “entire portfolio of clients” and private practice as a condition of joining Hershey, Ehresman says.

He only accepted the offer, which initially was for a counsel of intellectual property position, after receiving assurances that he would be able to have a long career with Hershey, the complaint says. He was promoted to the senior counsel role about midway through his tenure because Hershey valued his contributions, Ehresman says.

Then in October 2017 he was told his position would be eliminated at the end of the year, Ehresman says. A few days later, he says, he was hastily rushed out of the building and his security badge was deactivated.

He accepted Hershey’s severance offer only because he had no reason to doubt the company was telling him the truth about his job being cut, Ehresman says.

Hershey had “a highly promoted internal” policy and “publicly promoted objective” of increasing worker diversity, Ehresman says. His ouster and replacement was discriminatorily orchestrated to further that push, he charges.

Hershey didn’t immediately respond Feb. 7 to Bloomberg Law’s request for comment.

Smigel, Anderson & Sacks LLP represents Ehresman. No attorney had filed an appearance yet for Hershey.

The case is Ehresman v. The Hershey Co., M.D. Pa., No. 1:10-cv-00212, complaint filed 2/6/19.