Derrick Lewis was hurt at UFC Wichita long before he got hit in the gut by a Junior dos Santos spinning back kick.

Bob Perez, Lewis’ longtime coach, said Monday that Lewis went into the main-event bout with a fairly “major” knee injury. Lewis ended up falling to dos Santos by second-round TKO.

Perez said Lewis was training in wrestling last month when his “knee kept collapsing.” He had an MRI that they got back Feb. 12 showing issues with the knee, though Perez didn’t want to go into details. Perez said the UFC asked Lewis to get a second opinion and that doctor cleared him to compete.

“He wasn’t gonna pull [from the fight] anyway,” Perez said of Lewis. “That being said, training for this camp was really bad. He couldn’t do anything, honestly

“We couldn’t really do anything. From Feb. 12 to the fight, he couldn’t run. I basically was able to hold mitts for him and he was able to swim and do a seated, stationary bike. He could not train.”

Helen Yee of NBC Sports Radio was the first to report Lewis’ knee injury Sunday.

In the first round, dos Santos nailed Lewis with a nasty spinning back kick to the mid-section and Lewis doubled over. When dos Santos moved in for the kill, Lewis threw a huge haymaker that nearly landed. Some thought Lewis was playing possum, but he continued to appear injured for the rest of the first and into the second.

Perez said he told Lewis in the corner between rounds that he had to finish in the second. The coach, who trains Lewis out of Main Street Boxing and Muay Thai in Houston, saw the knee was giving him trouble and thought he might have broken ribs, like he sustained against Travis Browne in 2017.

“I knew he was hurt to the belly, but I didn’t know the extent of that, because Travis [Browne] actually broke his ribs,” Perez said. “Derrick was like, ‘I had to take a crap.’ No, two ribs were broken. So in my head, the ribs are broken again. I knew the knee was shot, I could tell by his movement that he just wasn’t there. He actually held the knee a couple times.

“So I’m like, ‘Dude, we’ve gotta finish now.’ If it would have gone into the third, I don’t think he could have even supported his weight. Backstage [after the fight], man, he was in a wheelchair. The leg was completely locked out. We really need to figure out what’s going on. No fighter is completely 100 percent, but he was definitely beaten up going into this fight.”

Perez said Lewis had a hard time cutting weight to make the 265-pound heavyweight limit. Then on fight day, Lewis felt dehydrated and drank a ton of water and sports drinks, which led to him ballooning up to 298 pounds, Perez said.

Despite all that, Lewis went into the Octagon and fought one of the best heavyweights on the planet. And had his moments.

“He went in there and freakin’ banged it out,” Perez said. “That’s what I love about that guy. There’s no fear in hm. There’s nothing but heart.”

If it were up to him, Perez said Lewis would not have fought at UFC Wichita. He was coming off two fights in two months in October and November, the latter of which was the UFC 230 main event against Daniel Cormier in New York. Cormier beat Lewis by second-round submission.

Lewis, 34, wanted some time off, but the UFC called him two weeks after New York to offer him a fight with Stipe Miocic in January, Perez said. Lewis turned that down, but accepted dos Santos for UFC Wichita a few weeks later, after the holidays.

“Derrick is like my family,” Perez said. “I need him to rest his body, rest his mind, rest up some of these injuries. He’ll make it very vocal — ‘UFC, don’t call me, don’t bother me.’ But they do. They’re gonna hit him up and they did hit him up. It’s really hard, man. He’s made it very clear. This is how he provides for his family. So if they’re offering him a nice payday to fight somebody, he’s gonna do it. It’s like putting that carrot in front of the horse. He’s gonna fight.”

Perez said he’s hoping Lewis (21-7, 1 NC) takes some time off now to get his knee injury straightened out. The coach is hoping “The Black Beast” doesn’t fight for another seven or so months, returning toward the late fall or end of the year. But Derrick Lewis is going to do Derrick Lewis — and Perez knows that.

“Derrick reached the pinnacle,” Perez said. “Madison Square Garden, heavyweight title versus one of the greats. And he did it on his own terms. He did it Derrick’s way. And that’s what I can’t get people to understand is what a freak he is, man. I’ve never seen anything like it. If Derrick can breathe, he can be the champion. I know that sounds freaking ridiculously dumb. But Derrick is just special like that.”

Perez also had some parting shots for the critics who blasted Lewis for his performance against dos Santos without knowing the whole story.

“All these trolls and all these haters and all these f*cking idiots — Derrick sucks? Come fight him, see how that goes for you, dumbass,” Perez said. “These reporters that have never competed in anything other than a pie-eating contest, they’re having trouble breathing while they’re f*cking typing because they’re morbidly obese, they want to question Derrick about his f*cking cardio? F*ck you.

“We’ve had a couple of guys show up to the gym thinking they could beat Derrick in a fight and they got slept, bro. They got slept. People just don’t get how hard this is, how hard it is on the fighter, what they have to do in preparation. The aches, the pains, the heartache, the blood, sweat and tears — the cliche stuff. It’s f*cking true, man. These guys go through so much and these fans are just the most wishy-washy flip-flopping — they’re worse then politicians, man. You’re winning and it’s ‘We love you, you’re the best, your balls are hot, you’re the Black Beast.’ And you lose, ‘Aw, f*ck you, you suck!’ These fans, they’re f*cking terrible, man.”