People.com said it took four months and 17 doctors before it was clear why she felt "almost completely unable to move."
The diagnosis was made after the "3rd Rock from the Sun" actress spent two weeks at the Mayo Clinic in Minnesota.
"It's time for me to be upfront with you about something that's been going on with me," she wrote on Facebook Tuesday.
"Lying down I'm fine, which is great for writing or killing time on social media, but it's kind of disastrous when you're in a sitcom that requires tons of physical comedy," she said. "My immune system has decided to go rogue [and] attack my muscles."
She went on to say she is undergoing treatment, feeling better and back at work.