“West Wing” star Martin Sheen attempted to save Rob Lowe’s job when he staged a last-minute “intervention” between the egotistical actor and the rest of the cast that convinced Rob to reconsider plans to quit the show.

And for now it appears that Rob wants to stay on, “West Wing” insiders say, and he and the show’s producers are working out the terms of a new agreement — which will include a hefty pay raise.

Rob was enraged this season when producers of the highly rated NBC show tripled Martin Sheen’s per-episode fee to $300,000, gave other actors big raises, but kept Rob at his starting salary of $75,000 per show.

“Rob demanded more money and the producers said, ‘We’re not giving you another dime,'” a source close to the show told The ENQUIRER.

“Rob reacted by quitting the show in a huff.

“But Martin didn’t want to break up the award-winning cast combination on ‘West Wing.’ And what’s more, he truly considers longtime friend Rob one of his sons.

“He persuaded Rob to sit down and talk to his cast mates — including John Spencer, Allison Janney and Bradley Whitford. And they managed to convince him that he was throwing away the best job he’s ever had.

“The cast made it clear to Rob how lucky he is to be on a hit show that has four or five good years left in it. They pointed out that Rob doesn’t have much of a movie career, so the best he could hope for was to get a television pilot — and even if that got picked up, it wouldn’t be a hit on the level of ‘The West Wing.’

“Then Martin told the show’s creator, Aaron Sorkin, that he felt Rob was an important part of the show and convinced him that if a hit show ain’t broken, you don’t fix it. Now the producers are going to beef up Rob’s story line, and come up with some more money for him.”