Edwin Meese III offered a cordial greeting to his visitor, Richard V. Allen, and then he let him know where things stood.

The president wanted Allen's resignation, Meese said. There was no other way out of it.

The word came as no surprise to Allen, as he sat yesterday afternoon in that prestigious corner office that had belonged to past White House national security advisers but had never been his. The newspapers had even printed the name of his successor.

But Allen was not yet ready to yield. As he recalled, and Meese later confirmed, Allen said that he worked for the president and no one else, and if that was what the president desired, then he wanted to hear it directly from him.

It was 2 p.m., time for Allen's scheduled meeting with President Reagan. He left the office of the counselor to the president, walked around the bend in the corridor and was ushered into the Oval Office, where he quietly made his last stand.

"I suggested to the president that I wanted to be reinstated, but I understood he might have other ideas," Allen said.

The president had other ideas. And so, on the day in which he was finally exonerated of any illegality or even impropriety in the scandal that had become linked with his name, Richard Allen left the permanent employ of the man he had worked for years to elect and then serve.

Allen lost his job, in the end, not because of the $1,000 in cash he received from Japanese journalists; not because of the three watches he received and kept; not because of the contacts with his former business associates; and not because of the errors on his financial disclosure form. The Justice Department ruled weeks ago that he had broken no laws, and the White House counsel's office said yesterday (after an inexplicable delay) that he had violated no codes of conduct.

Allen was replaced as the president's national security adviser mainly because the president and his top advisers concluded they did not like the way things had worked out with him in the job.

Coordination and communication between Allen and Secretary of State Alexander M. Haig Jr. had been shattered by the friction and hostility that existed unchecked between the two men from the outset of the administration.

It was not that it was mostly Allen's fault: Haig had managed to involve himself in repeated clashes with Defense Secretary Caspar W. Weinberger and a number of other Cabinet colleagues, as he seemed to view every debate over policy and planning and structure as a struggle over the territorial imperative.

But tensions between the two men and their staffs continued to flare, fueled by reports that made their way around the State Department and the White House that Allen was frequently critical of Haig in private meetings with outsiders and at cocktail and dinner parties.

The president's top advisers--chief of staff James A. Baker III, deputy chief of staff Michael K. Deaver and Meese (Allen's staff supervisor)--seemed to spend increasing amounts of time trying to resolve the intramural quarrels before they got to Reagan. But there were some things that they could not keep from him.

Like the problem with the morning intelligence briefings. Presidents have traditionally received their daily briefings on international intelligence developments from the national security adviser. But Haig--apparently chafing at what he feared was a daily opportunity for Allen to snipe at him--insisted to the president that he wanted to be present at the morning briefings, too, or at least have another State Department official there.

So Haig or Deputy Secretary of State William P. Clark began attending the daily briefings. But this proved unsettling to Weinberger, who let it be known that Defense wanted to be there, too.

Reagan's ultimate response was to cancel his morning briefings from the national security adviser, saying he would simply read the data from written reports. Some White House officials said privately at the time that the president thought that his morning sessions with Allen had been mainly a waste of time. But one senior presidential adviser offered another view the other day: "The briefings had become unwieldy. It was like having to have a miniature National Security Council meeting each morning."

By this time, as Meese was later to concede, the coordination of the president's national security policy making had degenerated into "confusion."

Haig was communicating with the White House by talking variously with Meese, Baker, Deaver and the president. Often, key guidance and impressions were passed through what proved to be a crucial, informal back-channel: between Deaver and Clark, who had been placed at State mainly because he was an old Reagan ally who could serve as a conduit between Haig and the Reagan men the secretary hardly knew.

Again, this confusion of communication was not of Allen's origin; Haig often seemed to see things in terms of combat rather than collegiality. But the problem just made things worse for Allen.

Consider the crisis last fall. It began when Haig responded to a newspaper columnist's charge that the president was unhappy with him by counter-charging that there was a "guerrilla" in the White House conducting a campaign to get him. Oddly, Haig later maintained that he did not mean to implicate Allen that time. Nonetheless, the president finally felt called upon to get involved in the matter--and so he called Haig and Allen into his office and warned them to cease and desist.

Meanwhile, within the White House and the State and Defense departments, there were complaints that Allen's NSC staff was doing a poor job of coordinating policy. And within that staff, some complained that Allen was not providing proper leadership and direction.

There was a feeling among some in the highest echelon of the White House that Allen's days as national security adviser were near an end even before the controversy concerning the $1,000 and the wrist watches erupted in November. And in that sense, some felt that the controversy bought Allen some temporary job security, as it seemed unlikely that the president would move summarily to oust Allen while he was maintaining his innocence and before a thorough investigation could be done.

But among those at the top of the White House command, the conclusion that Allen must be replaced came more quickly to some than to others.

Deaver is said to have favored replacing Allen even before the hint of scandal surfaced, Reagan officials say. He was said to have been angered that Allen had allowed the feud with Haig to get out of hand and especially, after the controversy surfaced, felt that Allen should leave office because he had damaged Reagan with his faulty judgment.

Baker came to feel that Allen's bad judgment in the matter left a taint that could not be erased, and that he should be replaced, according to informed sources.

Both Deaver and Baker believed it was essential to elevate the job of the national security adviser, which had been subordinated to Meese. And the president, too, was said by one knowledgeable official to have come to the same view.

But neither Baker, Deaver or the president ever communicated that directly to Meese. The first the counselor to the president knew of those views was when they were disclosed in a newspaper article that appeared just before Christmas.

Meese had been resisting suggestions that the job be elevated out from under his supervision; and he had been Allen's staunchest defender among the White House triumvirate. But while the president was spending his Christmas week in Palm Springs, Calif., Meese telephoned Reagan to say that he had concluded that the job should be upgraded, and Allen should be replaced with Clark. The decision was made. The president's advisers would urge Allen to resign voluntarily. If he would not, then he would have to resign, anyway. Word of the decision to replace Allen with Clark found its way quickly into print.

And meanwhile, back in his home in suburban Virginia, Allen read the newspaper account and insisted that he did not want to resign. But he conceded at one point, in those final days, that he felt as though he was hanging onto the gunwales and they were pounding on his fingers.