Budget director David A. Stockman retained his job precariously last week despite the fact that two of the three chief presidential advisers, Michael K. Deaver and Edwin Meese III, urged that he be replaced, according to informed sources.

But Stockman's future in the administration remains far from settled, White House sources say, as President Reagan and his top advisers watch whether Stockman can deal effectively with Congress in days to come.

At the time of the president's showdown with Stockman last Thursday, White House Chief of Staff James A. Baker III was the only one of the three top assistants who strongly urged Reagan to allow Stockman to retain his job, informed sources said.

Baker is said to have argued that Stockman is the administration's most capable domestic policy official and that his participation is crucial in the final weeks of decisions for the 1983 budget.

Reagan agreed to keep Stockman, although he was furious at Stockman's comments criticizing the Reagan economic program in a magazine article. But Reagan will continue to pay close attention to Republican leaders' assessments of Stockman's credibility, according to presidential aides.

If congressional concerns deepen, these sources said, Stockman could be asked to resubmit his resignation, with the president this time accepting it and making appropriate expressions of regret.

Stockman's fortunes in the high councils of the White House under-went a dramatic shift between late Wednesday, the day after the offending article in Atlantic Monthly first hit Washington, and Thursday morning, when the president decided to summon Stockman to the Oval Office.

On Wednesday, a senior White House official was instructed to tell inquiring reporters that the White House was "rallying around" Stockman. But on Thursday, after Reagan and his aides read the article or excerpts from it and after the first reactions from congressional Republicans rolled in, the president and some of his advisers became angrier.

Deaver was the most vociferous of Reagan's three top advisers. According to informed sources, he felt Stockman should be replaced swiftly because his quoted doubts had compromised public faith in Reagan's credibility. Deaver argued that Stockman showed poor judgment and questionable loyalty in speaking so candidly to a journalist.

Meese, although less vocal on the subject, was said to have shared Deaver's view that Stockman should leave his job. Departing political director Lyn Nofziger also favored Stockman's dismissal, sources said.

Baker felt Stockman deserved to be chastised but not forced out. Appearing yesterday before the American Council of Life Insurers, Baker offered some public job insurance for Stockman. Asked if he thought Stockman would survive in office, Baker said: "In my opinion, he will."

Baker went on to say that many of the most damaging passages of the magazine article represent not quotes from Stockman, but "conclusions of the writer of the article," Washington Post Assistant Managing Editor William Greider.

The perception that Stockman's fate now depends in large measure on Republican leaders in Congress is shared by some of Stockman's close friends and by those Republicans themselves, according to informed sources.

The question of Stockman's credibility with Congress is being debated among Republican leaders there. For now, he has been asked by the White House to limit his visibility on Capitol Hill.

According to a senior aide to one of the key Senate committee chairmen, the argument is between pragmatic considerations--"everybody knows he's the brightest guy downtown . . . the only one who understands these budget issues"--and the fear that Stockman did permanent political damage.

According to Republican sources, the Senate leadership is feeling the aftereffects of Stockman's troubles. These sources said no one in the White House is taking Stockman's normally active role in maneuvering over the "continuing resolution" that Congress must approve by midnight Friday to prevent the government from closing down for lack of funding.

Reagan has threatened to veto a resolution that allows spending at higher levels than he wants, but Congress appears headed toward passing such a measure.

"It's a natural situation for Stockman" to become Reagan's chief negotiator again, one source said. "But he's just not evident."