An unusual cooperative effort by the Carter and Reagan administrations, including a series of private messages delivered in Washington and Seoul, was instrumental in saving the life of South Korean opposition political leader Kim dae Jung, according to sources in both the Carter and Reagan camps.

South Korean President Chun Doo Hwan commuted the death sentence against the opposition leader on Friday, three days after Ronald Reagan, in one of his first acts as President, signed an invitation for Chun to make an official visit to the United States.

Reagan administration aides denied that there was an explicit swap of Kim's life for the Washington visit. But they did not deny that the trip figured in importannt fashion in the discussions of Kim's fate. Seoul was told according to the sources, that there could be no trip to Washington by the new Korean leader if the opposition figure was executed.

Kim, among the most prominent and most controversial mainstream political leaders in South Korea since he came close to winning the presidency 10 years ago, was arrested inMay as a military faction headed by Chun cemented its power in the face of widespread protests. Kim was sentenced to death by a military court Sept. 17 on sedition charges, which the State Department called "far-fetched."

The Carter administration was appalled by Chun's power play, which ended a fragile drive toward democratization in South Korea, but was unwilling or unable to exert enough leverage to force a change. Although the United States gradually accepted Chunas Korea's new leader, it continued to view the execution of Kim as a serious threat to U.S.-Koreaan relations. t

Officials of the Carter and Reagan administrations, in similar words, said their concern about Kim was not just personal or humanitarian, but arose from the belief that his execution would be an event of large-scale symbolic and political importance throughout the world. This would make it much more difficult, Chun was told by both administrators, for the United States to work closely with Korea in the future.

After a major internal battle, the Carter administration decided to make most of its pleas for Kim's life in private rather than in public. For example, State Department legal officer Jeffery H. Smith spent 4 1/2 weeks in Seoul observing Kim's Court martial -- which was condemned by Amnesty International as "failing to meet internationally accepted standards of fairness" -- but Smith's report was never permitted to see the light of day, on grounds that it would complicate the task of winning clemency for the condemned leader.

Then-Secretary of State Edmund S. Muskie authorized several private messages telling Seoul that Kim's execution would risk "the abuse of the relationship" with Washington. Among those who sent strong messages to Seoul, in addition to the State Department, were then-Defense Secretary Harold Brown, who traveled to Seoul to discuss the Kim case with Chun, and Carter's CIA director, Stansfield Turner.

Reagan's election in November was widely seen as decreasing U.S. interest and pressure for clemency, and thus sharply increasing the chances that Kim would be executed. The private assessment of some of Reagan's aids, matched by those of some of Carter's administration officials, was that Kim would not be put to death during the U.S. presidential transition period to spare the incoming administration embarrassment.

Shortly after the election, Muskie contacted both the Reagan foreign policy team and senior Republicans on Capitol Hill to make the case for clemency for Kim, and its importance to the U.S. national interest. The response from both quarters was positive.

Senate Republican leader Howard H. Baker Jr. (Tenn.) sent an emissary to Seoul in early December to ask that Kim's sentence be commuted. The same message bearer, staff aide Cran Montgomery, also carried a private message from Sen. Edward M. Kennedy (D-Mass.).

The most important message, without question, was from Reagan foreign policy adviser Richard V. Allen, now presidential national security adviser, saying that in the view of the incoming administration, Kim's execution would have serious consequences for Korea's bilateral relations with the United States as well as its relationship with Japan and other vital countries.

In a November conversation with Gen. Lew Byung Hyun, chairman of the Korean joint chiefs of staff, Allen discussed the possibility of a Washington visit by Chun at the time of the inauguration. The idea of a visit was refined and discussed at greater length by Allen later with Korean Ambassador Kim Yong Shik and embassy minister Shon Jang Rae, a confidant of Chun.

For some in the Reagan camp, dangling a trip to Washington was seen as a means of staving off Kim's execution long enough for the new administration, after taking office to make a plea for his life. Reagan's strong backing for Korean security as well as the outspoken opposition to U.S. troop withdrawls by his designated secretary of state, Alexander M. Haig Jr., made a compelling case for a reciprocal gesture by Chun to pave the way for improved relations with the United States in the Reagan era.

Washington was not informed before Jan. 20 that Chun would commute Kim's death sentence before setting forth on his official trip, which is to begin tomorrow in Los Angeles. But shortly after Reagan's official invitation was extended, Chun sent word of the action he was preparing to take.

Last Friday, shortly after it was announced, the Reagan State Department welcomed the clemency for Kim, calling it "a Korean decision" that will serve to "improve the atmosphere" of relations between Washington and Seoul.