Anastas I. Mikoyan, 82, a former president of the Soviet Union and a prominent figure in the Communist Party and Soviet government for half a century, died Saturday "after a long and grave illness," the official Tass news agency reported yesterday.

Tass said the death of Mr. Mikoyan had been announced by the Central Committee of the Communist Party, the Supreme Soviet (or parliament) and the Council of Ministers "with deep sorrow." The announcement referred to Mr. Mikoyan merely as a "veteran member of the Soviet Communist Party" and a "personal pensioner."

In fact, the old Bolshevik held high party and government posts longer than any other figure since the Communists took power in Russia in 1918. His career reflects the major developments in the Soviet party and state from its inception almost to the president. Not only did he play a role in these events, but he survived them. His ability to remain in power despite the purges, unheavals and disasters that have befallen his country since the early years of this century became a legend in his lifetime.

For a brief time Mr. Mikoyan was a colleague of Lenin, the father of the Russian revolution. On Lenin's death, he became a supporter of Stalin in the face of a challenge from the brilliant and charismatic Leon Trotsky Stalin prevailed - and Mr. Mikoyan porspered.

He remained close to Stalin through the brutal campaign to force the peasantry onto collective farms in the late 1920s and early 1930s. He survived the Stalinist purges of the 1930s - the grave yard for most old Bolsheviks - World War II, and - by luck - a new wave of purges that Stalin was planning when he died in 1953. For it was learned later that Stalin planned to purge Mr. Mikoyan had he lived.

Stalin was succeeded by George M. Malenkov as chairman of the Council of Ministers, or premier, and by Nikita S. Khurshchev as first secretary of the CCommunist Party. In 1955, Malenkov was replaced by Nikolai A. Bulganin, an ally of Khruschev. Mr. Mikoyan supported this change and became a first deputy premier.

Two years later, he backed Khrushchev in the face of maneuvers by a majority of the party central committee to oust him. Khrushchev prevailed and eventually became head of both the Communist Party and the Soviet government. In 1962, Mr. Mikoyan was dispatched to Washington and then to Cuba as Khrushchev's emissary during the missile crisis.

In October 1964, Mr. Mikoyan by then the chairman of the presidium of the Supreme Soviet, or president of the Soviet Union, entertained Khrushchev in the Crimea while Leonid I. Brezhnev and Alexei A. Kosygin carried out the maneuvers that forced Khrushchev into retired as the president of the Soviet Union in 1965. He remained a member of the Supreme Soviet until 1974.

Such was his reputation for survival and political acumen that the following joke was told about Mr. Mikoyan after Khrushechev's downfall. Khrushechev is in exile in the United States and a Czarist regime has been installed in Russia headed by Czar Nicholas III. Khrushchev wishes to visit his homeland and communicates this wish to Nicholas. The Czar promptly seeks advice from his most trusted colleague, Mikoyan.

But if Mr. Mikoyan survived, not all themselves of his family did. A son was imprisoned by Stalin during World War II. Apparently this made no difference in the relations between the two men, although Mr. Nikoyan reportedly said years later that "Stalin held us in his hand. Only one escape was left to us (suicide). At the end of Stalin's life, I was about to be executed."

Outside of the Soviet Union, Mr. Mikoyan was often referred to as "the wily Armenian." He was an expert on foreign and domestic trade matters and a keen negotiator. He had a reputation for wit and charm. He was a stylish dresser.

Mr. Mikoyan was among the most widely traveled of Soviet leaders of his generation. He first visited the United States in 1936 as commissioner of trade. He reportedly was much impressed by American methods of merchandising and tried to introduce some of these practices in the Soviet Union. He also traveled widely in Europe, Africa and Asia. In the Khrushchev years, his missions abroad were as often as not diplomatic rather than commercial. He gave numerous speeches and press conferences outside the Soviet Union and appeared on such programs as "Meet the Press." He was regarded as a Soviet with whom one could do business.

He also was esteemed by western Kremlin-watchers for his skill in understanding - and reacting to - the inner workings of Soviet politics.

Khruschev delivered his famous "secret speech" denouncing Stalinism and the "cult of personality" at the 20th Congress of the Communist Party in 1956. But before Khrushchev spoke, Mr. Mikoyan told the congress that Stalin had acted illegally for the last 20 years of his rule.

After Khrushchev's fall, he joined other leaders in denouncing the plan to put missiles in Cuba as one of the former premier's "hare-brained schemes." Moreover, Mr. Mikoyan followed the more moderate line of the new leadership on the question of Stalin - Stalin made errors, but his contributions to his country were great.

Anastas Ivanovich Mikoyan was born in Sinain, a village near Tiflis, now Tbilisi, the capital of Soviet Georgia. His father was an illiterate carpenter, but he propered at his trade. Young Anastas attended the Armenian Theological Seminary in Tiflis (Stalin got his formal schooling in the Russian Orthodox seminary in the same city).

It was during his student days that he first became involved in a revolutionary activity. He first joined the Kadets, or Constitutional Democratic Party. In 1915, he joined the Bolsheviks, the radical wing of the Russian Social Democratic Labor Party.

In March 1917, when the exar was overthrown, Mr. Mikoyan was active in Baku, a city on the Caspian Sea and an oil center. He became editor of the official Bolshevick Armenian-language newspaper, the Social Democrat. He also wrote for other Bolshevik newspapers.

A year later, he was commander of a Bolshevik detachment fighting against anti-Soviets in Azerbaijan. He was promoted to brigade commander in the Red Army in 1918. Having been wounded, he returned to newspaper work in Baku.

There followed an incident the details of which still are not clear. In September 1918, German and Turkish troops were closing in on Baku. Mr. Mikoyan and other Bolsheviks sought to escape by ship to friendly territory. Instead, they were forced to land in Krasnovodsk, a city controlled by anti-Bolshevik elements and the British. A list of 26 "Baku commissars" was drawn up and they were executed.

Although he was among the more prominent among those captured, Mr. Mikoyan's name was not on the list. He was imprisoned rather than executed. How this came about has not been fully explained.

Early in 1919, Mr. Mikoyan was released from prison in connection with a general strike in Baku. He returned to underground activity. He travelled to Moscow on one occasion, where he met Lenin, and then returned to Baku. He was one of the major planners of the captive of that city by the Red Army on May 1, 1920.

Mr. Mikoyan already was an ally of Stalin. Following the establishment of Soviet rule in Transcancasia, he held a number of important provincial party posts. He also rose in the government hierarchy. In 1926, he was named commissar for domestic and foreign trade, a post he held for four years.In 1930, he became commissar for supplies and in 1934 commissar of food. He was named a deputy chairman of the council of ministers in 1937, a post he held until 1946. He also was commissar for foreign trade in this period.

During World War II, he was chairman of the committee for provisioning the Soviet Army and then a member of the State Defense Committee. He was minister of domestic and foreign trade until 1955, when he became a vice premier.

He became president of the Soviet Union in 1964 and resigned a year later.

Mr. Mikoyan's real power derived from his standing in the Communist Party rather than from his government offices. He became a member of the Central Committee of the Communist. Party in 1923. In 1926, he drew closer to the inner sanctum as a candidate member of the party politburo. He became a full member in 1935 and retained his membership until 1966.

He rose through the party ranks because of his loyalty to Stalin. He helped the dictator consolidate his hold on the party and the country and his reward was promotion. Having achieved promotion, he helped Stalin in tasks that the latter could not have undertaken without complete control. One of the foremost of these was the collectivization of the peasantry process that cost an untold number lives. He also supported Stalin through the purges and the great "show trials" of the old Bolsheviks the 1930s.

Mr. Mikoyan continued to occupy an honcred place in his country after his retirementt. He remained a member of the Supreme Soviet until 1974. His decorations over the years included four Orders of Lenin, the Order of the Red Banner, and the Hero of Socilaist Labor.

His death leaves only Vyacheslav M. Molotov and Lazar M. Kaganovich as the only two men still alive who were close to Stalin.Both have long been in semidisgrace.

In 1920, Mr. Mikoyan married Ashken Lazarevna Tumanyan, his childhood sweetheart. They have five sons, one of whom was killed as a pilot during World War II. Mrs. Mikoyan died while her husband was in Cuba persuading Fidel Castro to agree to the withdrawal of Soviet missiles and bombers in the wake of the missile crisis of 1962.