Melissa Gilbert really has suffered for her art! The star struggled with back pain while on tour with the Little House on the Prairie musical — and only found out why when the tour wrapped earlier this month.

Gilbert said she met with a neurosurgeon in Los Angeles and “He came in and said, ‘Your back is broken, and it has been for months,’ ” the 46-year-old told People magazine. “I sort of was in shock for a while.”

Melissa — who played Laura on the original Little House TV show and Ma in the musical — fought through the pain for the sake of the production.

“I would balk and fight it and say, ‘I’ve got to do the show,’ ” she recalls, telling herself: “If it got really bad and I lost feeling in my legs or couldn’t move, I’d go to the ER.

“I thought doing a musical at 46 playing a woman in her late 20s, early 30s was amazing enough. But doing it with a broken back buys me a little more street cred.

“One of the things that is great is that I’ve lost about a half inch in my height and I will get that back.

“That’s really cool.”