Ludvik Svoboda, president of Czechoslovakia at the time of the 1968 Soviet invasion, died yesterday in Prague after a long illness. He was 83.

The Czech government news agency quoted a medical report as saying that Svoboda died of heart failure after a "difficult illness." Expressing "profound grief," the government said a special committee had been organized to prepare for a state funeral.

The white-haired, professional soldier, who was widely regarded as an honest man, played a crucial role in the two most fateful events in recent Czechoslovak history. In 1943, when he served as defense minister, Svoboda threw his support to the Communishs when they took over the country in a February coup. Twenty years later, as president, he legitimized the Soviet invansion and cast his lot with the new regime installed by Moscow.

Despite his role in 1948 and 1968, and his well known sympathies for the Soviet Union, Svoboda enjoyed considerable respect and even a degree of popularity among Czechoslovaks for standing up to the Russians in the aftermath of the invasion and preventing repressive measures against Alexander Dubcek and other officials of his liberal Communist regime.

The fact that Svoboda fought alongside Russian troops in two world wars gave him a unique standing in Moscow and sufficient power to obtain the release of Dubcek and his aides who had been seized by the Russians during the Aug. 21 invasion.

Svoboda's was a moderating influence on the subsequent regime in Prague until he retired in 1975 due to respiratory ailments and was replaced by Gustav Husak, the man who dismantled the Dubcek reforms.

Born in a Moravian village in 1895, Svoboda deserted from the Austro-Hungarian Imperial Army during World War I and fled to Russia, where he organized and led a legion of other Czechs and Slovaks that fought alongside the Russians.

After the war, Svoboda rose in the ranks of the Czechoslovak Army and was in charge of a battalion at the time of the 1938 Munich crisis. After Nazi Germany occupied large parts of Czechoslovakia, Svoboda went underground. He organized Czechoslovak refugee units in Poland, and when that country fell in 1939, he moved to the Soviet Union as head of the Czechoslovak Army Corps.

At the end of World War II, Svoboda was appointed defense miniter by President Edward Benes. But Svoboda did nothing to prevent the cOmmunish seizure of power in 1948, and he joined the Communist Party that same year.

In 1950, Svoboda was forced out of the military and placed in charge of the State Sports Organization. The next year he was imprisoned in Stalinist pruges.After his release he lived in obscurity until Nikita Khrushchev inquired about him. The inquiry led to his return to public life as a military writer and head of a military academy.

Svoboda retired in 1959 and was subsequently named a hero of both the Soviet Union and Czechoslovakia. In 1968, when liberal party elements ousted the conservative regime of Antonin Novotny, Svoboda was elected president on March 30 on the recommendation of Dubcek.

Dubcek and his colleagues, facing mounting suspicion from Moscow over their liberalization policies, selected Svoboda in an effort to allay Soviet fears. Five months later, after the Russians deposed Dubcek, Svoboda flew to Moscow, insisting the Dubcek and three other top officials be released from custody.

The Russians gave in and Dubcek, with his aides, joined Soviet-Czechoslovak summit talks on Aug. 24, 1968. Upon his return to Prague, Dubcek was allowed to keep the party leadership for another eight months before being ousted. Svoboda in turn gave his backing to the Husak regime.

Svoboda was reelected president in 1972. He retired three years later and was replaced by Husak.