After an intricate struggle during which he appears to have outmaneuvered advocates of internal repression and a nationalist foreign policy free of U.S. influence, South Korean President Chun Doo Hwan departed for a state visit to Washington firmly in control of his government.

While little is known about the tense behind-the-scene maneuvers, observers here believe that a group of hard-liners had sought to put more distance between South Korea and the United States and that the fate of opposition leader Kim Dae Jung's death sentence had been the focus of their struggle against Chun.

Chun's successful effort to build a consensus for sparing Kim's life was seen by diplomatic observers here not only as a defeat of the hard-liners but also as a personal triumph that offers Chun the chance to pursue a more moderate domestic course.

Observers here have noted a lessening of influence of hard-liners, both military and civilian, suggesting that there would be no major foreign policy departures such as those advocated by younger nationalist officers. Yet Chun, in his airport speech before departing for the United States, underscored a new tone in bilateral relations.

His trip, Chun said, would "reaffirm the traditional friendly and cooperative relations between our two countries." But, he added, those relations are "rapidly shifting from the past pattern of one-way dependence into a system of reciprocal and mutually beneficial cooperation."

The 11-day visit is considered part of an explicit deal with the Reagan administration, which agreed to invite him if he spared Kim's life.

Those who have followed the Chun government closely in the last several months believe the outcome of Kim's case resolved a division that had evolved gradually between the former general and some of his early military supporters.

Within that group of generals, colonels and some civilian aides were those who pushed through a harsh reorganization of the press, a massive purge of political figures and a forced realignment of some big industries. They also resented past American influence in South Korea and favored a more nationalistic course in dealing with the world.

They had insisted on the execution of Kim, who was convicted on sedition and other charges last September. Chun at first appeared to agree. In early December, at least one embassy was bluntly informed by the presidential office that Kim would definitely be executed soon.

Reports were leaked here of an intense debate between hard-liners and those who argued that Kim's execution was not worth risking international condemnation, the disapproval of a new administration in Washington and renewed instability at home.

In the opinion of some diplomats here, the White House invitation gave Chun the leverage to decide on a commutation of Kim's sentence. Relations with the United States, which bases 39,000 troops here, are still considered of enormous importance, despite resentment of foreign intervention. Exchanging Kim's life for an unequivocal demonstration of U.S. support, said one Asian diplomat, "was too good a bargain for anyone to resist."

At one point, many observers saw signs of a shaky president who seemed to change directions sharply. Chun is said to have decided at one point against the drastic press reorganization. Two days later the plan was announced. Sweeping decrees were issued by obscure colonels who seemed to operate with great authority.

The signs of division have disappeared since Kim's fate was resolved, these observers say, and Chun seems to have taken firmer control.

In the eight months since he took real power in a military crackdown, the 50-year-old former general has discarded old authoritarian forms and replaced them with new ones. Many critics see no real difference in substance. The lifting of martial law Saturday ended military press censorship, for example, but editors have been given strict instructions about what they can and cannot print. "We know we have got to behave," one journalist said. Retired colonels have been assigned to each newsroom in major papers.

Elections for a full presidential term will be held next week and four parties are fielding candidates, including Chun's own military-backed party. But virtually all prominent former politicians were swept from the scene in a purge, and no one of national stature will oppose Chun. A new election law rigidly restricts campaigning.

The right of public assembly is tolerated in principle, but there are many restrictions and police have power to clamp down inside campuses.