When CIA Director William J. Casey appointed Max Hugel as the nation's chief spymaster, the action so astonished top-ranked White House officials that Casey wrote a letter to President Reagan explaining his unusual selection.

"It was a coup by Casey," a well-placed White House aide said yesterday.

If there was anyone in the White House who wasn't surprised by that action, which was made public in mid-May, he couldn't be found yesterday. One well-placed official said that the president's top triumvirate of aides -- chief staff James A. Baker III, deputy chief of staff Michael K. Deaver and counselor Edwin Meese III -- were all caught off guard by Casey's decision.

There was an immediate outcry from intelligence officials as well as those who worked with Hugel in the 1980 Reagan campaign. Hugel's job as deputy CIA director for operations is one of the most senstive and important in the government.

The response prompted Casey to defend his selection. In his letter to Reagan, the CIA director argued that Hugel possessed valuable managerial skills and had proven himself in the Reagan campaign. Casey also claimed that Hugel's campaign work organizing ethnic groups was similar to organizing covert operations.

Casey said in his letter that he had known and trusted Hugel for 20 years and wanted someone from outside the intelligence community to prevent in-fighting for the job.

"Does the White House know about this?" was the first response of Stuart K. Spencer, Reagan's chief 1980 campaign strategist, to Hugel's appointment.

Despite such warning signals, which included strongly voiced private objections from prominent members of the intelligence community, the White House did not overrule Casey. High-placed officials deplored the choice but said it was Casey's to make.

Yesterday, Casey declined to comment on his reasons for picking Hugel, who went into the CIA with him Jan. 21 as a special assistant and then was promoted to deputy director of administration, before being chosen to head the operations directorate.

But others in the administration tried to explain Casey's reasoning.

"Max had done a lot of overseas work," Meese told the Washington Post last week. "That's been a large part of his professional career as an overseas marketeer. Also, Bill admired his ability to manage things in the campaign and felt he would be the right person to put in that job.

"He restructured that particular segment of the agency by having, in essence, a lay administrator, a non-career administrator, and then had two career specialists in charge of the two halves, which they had not had before. . . . He was interested in having, as part of his total management plan over there, someone he could rely on 100 percent."

Such explanations have failed to satisfy CIA professionals.

A former deputy director of operations for the agency said yesterday that Hugel "substitutes profanity for thought" in a job that is one of the most important in the CIA.

"This person is in charge of assignments and judgments in the field of covert intelligence, picking station chiefs and deputy station chiefs in foreign countries, making the final decisions on covert operations and on personnel," this former official said. "This is the man who decides on whether or not a covert action is practically feesible. There is no substitute for experience in that area."

Another high-ranking career CIA expert questioned the wisdom of appointing anyone with a stocks-and-bonds background to be deputy director of operations (DDO).

"There is no way a DDO can be in stocks or commodities because sure as hell you're going to be accused of insider information, given the character of people you deal with and the information you receive," this CIA expert said. p

To understand why Casey was allowed to choose someone with such an apparently inappropriate background for the DDO job, it is necessary to understand the relation forged between Reagan and Casey in the presidential campaign.

The 68-year-old Casey, chairman of the Securities Exchange Commission during the Nixon administration, joined Reagan in February, 1980, when the Reagan campaign was spending money so fast the candidate feared he would be bankrupt long before the Republican convention. Casey introduced strick spending controls, and Reagan was so grateful that Casey became one of his most trusted aides, enjoying a position usually reserved for longtime Reagan insiders.

When Reagan won the New Hampshire primary two weeks later, he fired campaign manager John Sears and installed a collective leadership -- the forerunner of the present collective leadership in the White House -- consisting of Casey and Meese. Later, Spencer and Deaver became the chief operatives on the Reagan campaign plane, in effect sharing the campaign leadership.

Hugel, 56, already was part of the campaign when Casey arrived, but his role was a small one. He was Nashua town chairman in the New Hampshire primary, as the result of a recommendation of William Loeb, the influential publisher of the Manchester Union-Leader.

In a front-page editorial that inspried snickers among some Reagan campaign operatives, Loeb credited Hugel with a vital role in the election, calling him "the man with the answers."

Actually, there is support for Loeb's view by some campaign veterans. One knowledgable member of the campaign team said that Hugel did "a competent job" in organizing ethnic voters in the national campaign.

Another aide who spent a lot of time on the campaign called Hugel "a political idiot" who tried to over-schedule Reagan into minor events and who needlessly irritated political workers.

The least favorite example of a Hugel political brainstrom was his proposal for organizing 10 million volunteers who would call on another 20 million Americans and presumably win the election through their sheer weight of numbers.

On one occasion when a campaign aide disagreed with him, Hugel said that he would have fired the subordinate if they were in private business. It was pointed out to Hugel that this was the difference between business and a political campaign.

This story points up the quality that many believe attracted Casey to Hugel, a tough-talking, self-made man from the New York streets who made himself valuable as a man who got things done.

"He came up harder than the hard way," says an administration official who knows him well, "and sometimes when you do that everything isn't always neat and clean."

Casey, also a self-made man, has at times been accused of borderline conduct himself although he received high marks for his management of the SEC. He was the defendant in a suit that alleged violation of the securities laws and misrepresentation of the value of some stock.The suit was settled out of court.

But Casey has never made any secret that he prefers hard-charging operatives to those who strain at legal niceties. In choosing Hugel for the spymaster post, he once more put his philosophy into practice.