Jim Miller, the veteran mixed martial artist from Sparta, N.J., thought he was going to announce his retirement after a final bout at UFC 200 in Las Vegas. Win or lose, he planned to stand in the middle of the Octagon, thank his fans and call it a career. That’s what he thought his body was telling him to do.

After 11 years in MMA, including the last eight with the UFC, Miller was feeling the physical toll of 34 professional fights and endless days of training. At age 32, he was clinging to the rails and gingerly stepping sideways down stairs. No matter what time of the day it was, his body ached.

“It was one of those things where I started physically going downhill and having a tough time training,” Miller told The Post this week. “It didn’t matter if I was warmed up or not, every time I stood up, it would hurt my knees and hurt my hips. I just thought it was part of my progression in this sport.”

That’s why Miller figured appearing in one of the preliminary bouts at UFC 200 would be a good time to say goodbye.

“I knew I wasn’t planning on staying too much longer the way that I felt,” he said.

But weeks before the bout, Miller consulted a doctor, who took some blood tests and eventually diagnosed him with Lyme disease, a tick-borne illness that quickly responded to medication. Two days after beginning treatment, Miller said he “felt like I used to, and I trained a lot better than I’d been able to in a while.”

The result was complete dominance of Takanori Gomi of Japan. Miller won by technical knockout in the first round, improving his record to 26-8-1 and making him eager to get back in the Octagon as quickly as possible.

“I’m feeling pretty good,” Miller said. “I came into that fight healthy and not banged up and I’m ready to hop back in. I’d love to fight in the Garden [UFC 205], but I’m trying to fight before that. I don’t want to hang around until November.”

His body and spirits are much better than they were last March after UFC 196, when Miller lost a unanimous decision to Diego Sanchez. It was Miller’s fourth defeat in his past five bouts. Now he knows he was battling Lyme disease as well as his opponents.

“Problem is a lot of the symptoms are exactly what you’d expect after being a professional fighter for a decade,” Miller said, “joint pain, stiffness, an inability to stay focused. I thought I had rheumatoid arthritis.

“I had a tough camp for my fight last December [a loss to Michael Chiesa],” he added. “I was really worn out. Even after taking a few weeks off, I wasn’t really able to recover and then I hoped right into camp for my March fight. I had a really difficult time training. I knew it wasn’t the best thing to do, but I’m a fighter and I have to provide for my family so I couldn’t pass up the opportunity. Fortunately, things got better.”

A standout wrestler at Sparta High School, Miller began his MMA career in 2005 and joined the UFC in 2008. He and his brother Dan, a former UFC fighter, own their own gym in Sparta, aptly named Millers Brothers MMA. The father of four is an outdoorsman, who likes to hunt and fish and has no idea when he might have contracted Lyme disease, which causes fatigue and depression.

“I live in Northwest New Jersey in farm country,” he said. “There’s deer everywhere when the dogs aren’t chasing them away, and I’m always outside. I’ve pulled ticks off of me before. But all it takes is that one little one that sneaks up on you.”

Miller’s victory in Las Vegas was a milestone achievement. He joined Brock Lesnar as the only fighters who competed in UFC 100 and 200, winning in both events.

“I’m proud of the accomplishment,” Miller said. “It’s definitely harder to stay in the UFC than to get to the UFC. The average wash-out rate is only three or four fights. So to have more than 20 fights is definitely an accomplishment. It’s a very small group that has gotten to that point.”

But don’t start finalizing his resume just yet. Miller’s retirement plans are on hold.