What the rumor mills in this town had known for a long time was that James Baker wanted out of his job as chief of staff and promotion to a prestigious Cabinet job such as Treasury. The big surprise this week, therefore, was not that Treasury Secretary Donald Regan was asked to step aside for Baker, but that he was invited to move into Baker's job at the White House.

Does Regan have the political savvy, so well demonstrated by Baker, to deal with the infighting among department heads and to advise the president on the whole range of policy questions that lie outside his expertise in the economic area?

That question can't be answered for a while. But Regan -- although widely disliked in Wall Street, which regards him as a maverick and unpredictable -- is a highly successful executive who is trusted and admired by the president. More than once, the president has sided with Regan, even when there's been heavy artillery on the other side.

For example, Reagan ruled against Secretary of State George Shultz and with Regan when Shultz last year proposed more generous concessional aid to Third World countries. And contrary to the wishes of some of the existing White House political aides, the president seems to be going along with the radical tax reform package that Regan brought out at the end of the year.

Regan astonished everyone by producing a tax reform proposal that was endorsed by such tax reformers as Joseph A. Pechman, Walter W. Heller and consumer advocate Ralph Nader. "What have I done wrong?" Regan joked at the National Press Club.

The key to the president's decision to bring ex-Marine Regan into the White House is that Reagan and Regan are actually very much alike. Both have had long and rewarding careers, both are men of substantial wealth, and both are committed to the notion that the free-enterprise system is the best in the world.

These two Irishmen, who had never met before Reagan named Regan Treasury secretary in 1981, have an easy and comfortable relationship. On a personal level, they enjoy each other's company, swapping jokes -- some that couldn't be published in these columns. On a professional level, Regan has been the quintessential team player for Reagan economic policies, even when that meant an absolute reversal of a previously stated position or an excessively optimistic forecast that had to be revised downward later.

Nothing so aggravated the business community as a Sept. 8, 1983, Regan speech in Washington that not only jawboned bankers to lower their interest rates, but denied that the huge budget deficits facing the nation for the rest of the decade are a major cause of high interest rates.

The president, who had no strategy to deal with the deficit, eagerly bought the Regan analysis, which became a centerpiece of U.S. dogma at the Economic Summit and other international meetings.

By bringing Regan into the White House as his No.1 staff person, Reagan gets a highly skilled executive and former corporate CEO to shake up and manage the White House staff, and Regan -- even though he would have preferred to stay at the Treasury -- gets a new place in the sun with enormous power. I can't recall another Cabinet officer who so obviously enjoys the role he's played in Washington.

Both men have turned out to be poltical pragmatists. The president's ability to identify with mainstream, middle-class America, plus his winning personality, attracted votes in 1984 from citizens who confessed they're skeptical about the substance of his policies and programs.

Regan, equally pragmatic, was head of the Wall Street brokerage firm Merrill Lynch, where he made a fortune as a stock market innovator. There's no love lost between him and many in the financial community who denigrate him as a super salesman with few convictions that he's willing to stick to.

In his ebullient and somewhat irreverent way, Regan doesn't hesitate to discuss this love-hate relationship with Wall Street. Reminded in an interview a year ago that some of his old stock market colleagues say he flipflops, on demand, with shifts in the White House party line, Regan said:

"Look, Wall Street likes stability and caution. And I have never been stable or cautious in Wall Street's opinion."

In the past four years, Regan survived public squabbles, some of them bitter, with all other members of the ruling economic-policy apparatus -- OMB Director David Stockman, Council of Economic Advisers Chairman Martin Feldstein and Fed Chairman Paul Volcker. From time to time, he's also agitated his opposite numbers in Europe and Japan and in the international agencies such as the World Bank. But in all caes, his relationship to the president protected him. As Treasury secretary, he used to needle what he called the "West Wing." Now he will have the added security that comes with the closest proximity to the Oval Office.