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

Ousted “Meet the Press” anchor David Gregory was paid $4 million to leave NBC and signed a contract not to speak out against the network, sources told Page Six.

Gregory, 43, who moderated the show for six years, was unceremoniously dumped from the political program on Thursday after dismal ratings and months of speculation about his departure.

He has been replaced by NBC White House correspondent Chuck Todd.

A source said Gregory’s contract extended into next year, so NBC had to pay him for the rest of the term, plus an extra fee to ensure his silence.

In return, he was asked to sign a nondisparagement clause, which explains — despite the drama behind the scenes — his saccharine message on Twitter to announce his departure.

“I leave NBC as I came — humbled and grateful. I love journalism, and serving as moderator of MTP was the highest honor there is,” he tweeted, adding, “I have great respect for my colleagues at NBC News and wish them all well. To the viewers, I say thank you.”

But quietly, sources say, Gregory is “angry and humiliated” at the way he was treated by NBC suits who let him twist in the wind through months of painful speculation before finally pulling the plug. Page Six reported that Gregory confronted NBC brass last week after continuous ­rumors he would be replaced by Todd.

NBC has tapped Andrea Mitchell to host this week’s show, denying Gregory a chance to say farewell — or anything else — on air. Todd takes over on Sept. 7. NBC declined to comment.

Gregory’s future may be at CNN. Page Six has reported that the network was developing a pilot for him, while others speculate he could land on “Crossfire” with Newt Gingrich, which could use an authoritative moderator.

Meanwhile, Ann Curry, another NBC colleague who suffered an awkward departure, lent Gregory support via Twitter.

Quoting the Dalai Lama, she wrote: