Click to email this to a friend (Opens in new window)

Debra Messing has been told to “cut it out” by NBC bosses after she bad-mouthed fellow NBC star Megyn Kelly after appearing on her show.

The “Will & Grace” star was so put off by Kelly’s question to an audience member — “Is it true that you became a lawyer, and you became gay, because of Will? . . . I don’t know about the lawyer thing, but I think that ‘Will & Grace’ thing and the gay thing is going to work out great” — that Messing posted on Instagram, “Regret going on. Dismayed by her comments.”

While NBC insiders defended Kelly’s comments as “tongue-in-cheek,” Messing got a stern warning.

One exec told us, “Debra was told to cut it out by someone high up in the NBC Entertainment division run by Bob Greenblatt, via her agent or publicist.”

Messing’s rep declined to comment, but a source close to the actress said, “NBC has been nothing but supportive of Debra . . . No one asked us to do anything.”

Kelly also got on the wrong side of Wednesday’s guest, Jane Fonda, who snapped when the host turned the topic to plastic surgery. “We really want to talk about that now?” a displeased Fonda shot back.

NBC didn’t comment Wednesday night.