Wladyslaw Gomulka, 77, a former head of the Polish government and Communist party and the first Soviet bloc leader to press for the right of a communist country to pursue its own internal policies, died of cancer today.

Mr. Gomulka led the Polish party from 1943 to 1948. In 1956, after eight years in disgrace, he returned to power, defied the Kremlin and steered his country through one of its greatest political upheavals.

Historians believe that it was largely due to him that Poland avoided the trauma of a Soviet invasion in 1956 -- in contrast to Hungary, where thousands of people were killed when a bloody insurrection was put down by Soviet tanks.

In December 1970, when he ordered the crushing by force of workers' unrest along the Baltic coast, Mr. Gomulka was widely reviled and driven from office. At least 50 people are believed to have been killed when the security forces opened fire on rioters, a tragedy that molded the political attitudes of a generation of Poles and paved the way for a massive workers' rebellion a decade later.

Mr. Gomulka's name is thus inextricably linked with one of the recurring cycles of Polish history: euphoria and hope that ends in bloodshed and almost total disillusion with the leadership. His life thus provides insight into the underlying historical reasons for the rise and fall of the Solidarity movement.

The peak of his popularity came in October 1956 when, for a brief period, he was accepted by Poles as a symbol of their nation's sovereignty. He faced down a series of Soviet threats that culminated in the sudden arrival in Warsaw on Oct. 19 of a Kremlin delegation headed by Nikita S. Khrushchev and several Soviet generals.

That night, Soviet troops in Poland began moving on Warsaw in an attempt to block Mr. Gomulka's reelection as first secretary of the Communist party. They withdrew after Mr. Gomulka made it clear that the Polish army would resist any direct intervention, but that he would protect Soviet interests.

The national esteem that Mr. Gomulka enjoyed in 1956 gradually was squandered in subsequent years. Many youthful supporters were estranged by tightening party controls over society and the mass media and the rejection of all attempts to reform the country's highly centralized, state-run economy. He clashed violently with Cardinal Stefan Wyszynski, the head of the Catholic Church in Poland.

In 1968, Mr. Gomulka was one of the first communist leaders to argue in favor of a Soviet invasion of Czechoslovakia to crush the reform movement that was known as "the Prague spring" and regarded as a threat to the entire Soviet bloc. At home, he ordered the forcible suppression of student demonstrations. Although his wife, Zofia, was Jewish, he did little to prevent a vicious anti-Semitic campaign, now widely regarded as one of the most discreditable episodes in modern Polish history.

For most of the 1970s, Mr. Gomulka was almost a nonperson in Poland. In accordance with long-standing Polish traditions, his successors used him as a convenient scapegoat for the country's political and economic ills. It is only in recent months, following yet another turn in the Polish cycle, that a more balanced picture is emerging of his achievements and mistakes.

Last March, Mr. Gomulka was visited in a hospital in Warsaw by the martial law chief, Gen. Wojciech Jaruzelski. The visit was interpreted here as a political rehabilitation on the eve of his death.

Mr. Gomulka's rule also was reassessed in a series of press articles of which the most revealing was a collection of anonymous reminiscences by former associates, which appeared in a Krakow magazine entitled Zdanie (Opinion).

The article depicted Mr. Gomulka as an orthodox Marxist who understood the frailty of the Communist party's roots in Polish society. This led him to two paradoxical conclusions. On the one hand, he believed that communists had to come to terms with Poland's specific realities: a powerful Catholic Church, an intensely individualistic private peasantry, and a strong sense of national identity.

On the other hand, he was convinced that the Communist party never would be able to govern Poland democratically. In the brutally candid words of an anonymous friend, "He believed that power must be taken by force and that, if necessary, it must be maintained by force."

According to Zdanie, Mr. Gomulka won Khrushchev's confidence by telling him, "You are wrong if you have come to Poland thinking that our party could break the alliance with you. We need an alliance with the Soviet Union much more than you need one with us. One third of our territory depends on it."

Mr. Gomulka was referring here to the former German territories in western Poland that were awarded to Warsaw after World War II in compensation for land in the east that was lost to the Soviet Union. This redrawing of Poland's western frontier was not formally recognized by West Germany until 1970 in a treaty now seen as Mr. Gomulka's last major achievement.

In his personal life, Mr. Gomulka was modest, old-fashioned and disciplined. He was firmly opposed to "luxuries" such as private cars and villas. He failed to understand the rising expectations of his fellow Poles and, according to one associate, "looked upon the national economy as a peasant looks upon his farmyard." He and his wife had a son, Ryszard.

By the time martial law was declared last December, Mr. Gomulka already was a very sick man. But he was reported earlier as "seeing no possibility to settle the crisis other than through the use of force."

Mr. Gomulka was born on Feb. 6, 1905, in Krosno, now a town in southern Poland but then part of the Austro-Hungarian empire. His parents had earlier emigrated to the United States -- his father worked in the coal mines of Pennsylvania -- but returned to Krosno after becoming disillusioned with life in America.

It was partly due to his father's failure to make good in America that the young Wladyslaw was brought up as a socialist. A self-educated locksmith, he helped organize demonstrations and strikes, first for the Polish socialist party and then for the outlawed Communist party.

In the 1930s, Mr. Gomulka was twice sentenced to prison for communist activities. On the second occasion, he spent 18 months in solitary confinement and was not released until the outbreak of World War II in September 1939. This may have saved his life because in the interim most leaders of the Polish party were executed by the Soviets on the ground that they were "deviationists."

During the war, Mr. Gomulka remained in Poland and helped organize the communist resistance movement known as the People's Army. At the time, this group was overshadowed by the vastly more numerous Home Army, which was supported by the anticommunist government in exile in London. But when the Russians drove the Germans out of Poland, it was Mr. Gomulka and his People's Army that were installed in power.

Despite the dominant communist influence in the postwar government, Mr. Gomulka proceeded cautiously. He ruthlessly manipulated elections in order to eliminate the Polish Peasants' Party and its leader, Stanislaw Mikolajczyk. But he resisted Soviet demands for the collectivization of agriculture and advocated a concept of "national communism."

In September 1947, he opposed the Soviet dictator Joseph Stalin over the agriculture issue at the inaugural meeting of the Cominform in Poland. This was nine months before the historic split between Stalin and Marshal Tito of Yugoslavia, which resulted in Yugoslavia becoming the first communist country to break away from the Soviet orbit.

In Poland, Mr. Gomulka was outmaneuvered and eventually replaced as party secretary by Boleslaw Bierut, the leader of the "Moscow faction" in the party. It was only after Mr. Gomulka's dismissal in September 1948 that the Stalinist system proper was applied in Poland.

His reputation as an opponent of Stalinism stood him well in 1956 when Poland was gripped by worker unrest. He was the only communist leader who was simultaneously able to channel the workers' grievances in a peaceful direction and satisfy the demands of Poles for national independence and simultaneously to persuade a suspicious Soviet leadership to trust him.

Mr. Gomulka's achievement was what his English biographer, Nicholas Bethell, described as "a form of communism which both his people and the Soviet leaders were briefly able to tolerate," His failure was that, as a result of his stubborness and inflexibility, he also paved the way for today's bitter divisions in Polish society.