Sonny Gray’s rotten Wednesday extended off the field when he was left to defend himself against anonymous Twitter trolls.

The right-hander became the latest high-profile person to have to answer for questionable comments on Twitter from their past, as a tweet surfaced during Wednesday’s game from six years ago in which Gray responded to an unseen message to Sir_Peanut with “1. You didn’t go to college. 2. You are black. #followdaleaderleaderleader clap clap clap.”

Asked about the tweet following the Yankees’ 7-5 loss to Baltimore in the Bronx, Gray defended himself and said Sir_Peanut was a close friend, former minor league teammate Rashun Dixon, who also played in the A’s organization.

Gray said it was an inside joke between the two, calling the controversy “ridiculous.”

“I’m comfortable with who I am,’’ Gray said. “You can ask anyone in this clubhouse who I am and what I’m about. … If people are trying to dig stuff up, then ask [Dixon]. If people are gonna try to question my integrity and question who I am, then so be it, because I know who I am and if you know me, you know who I am.”

Gray’s Twitter account seemed to be deactivated following the game.

In the last few weeks alone, Atlanta pitcher Sean Newcomb, Brewers reliever Josh Hader and Washington shortstop Trea Turner were involved in firestorms after old tweets resurfaced that were racist or homophobic.

Unlike those examples, Gray’s post didn’t include any offensive language, and he insisted it was an exchange between friends.

“My past has helped shape who I am today,’’ Gray said. “If people want to question who I am, like I said, I’ll face that head-on because I’m not scared of my past. Everything that’s happened in my past has done nothing but made me a better man.”