Cardinal Stefan Wyszynski, Poland's spiritual leader for more than three decades, died here early today after a lengthy illness.

The cardinal's death, from cancer at the age 79, removes a principal figure in the country's political crisis: one of the main advocates of democracy in Poland, but also a moderating influence on the independent Solidarity trade union federation. It also creates a vacuum at the head of the Roman Catholic Church in Poland, the most powerful church in Eastern Europe.

Church bells rang out throughout Poland at 10 a.m., when the death was officially announced.A church spokesman said the cardinal died peacefully at 4:40 a.m. following the rapid spread of abdominal cancer.

Crowds of priests, nuns, and ordinary Poles immediately began filing past the coffin containing his body, which was laid out in a ground-floor reception room of the primate of Poland's Warsaw residence. On top of the closed gray coffin lay his red cardinal's hat, opposite it a portrait of his friend and compatriot, Pope John Paul II.

The two religious leaders held a final conversation on Monday -- by telephones hooked up to their respective sickbeds. Church officials said that the pope, who is recoving from an assassination attempt, blessed Cardinal Wyszynski.

The Vatican announced that the pope would be represented at the funeral on Sunday by his secretary of state, Cardinal Agostino Casaroli. Other delegations are expected from around the world.

[President Reagan sent a message expressing a "deep sense of loss" at the death of "a great leader and a great son of the Polish nation," the White House announced.]

Finding a successor to Wyszynski is complicated by the fact that there is no obvious candidate for the post. The choice of a successor to Cardinal Wyszynski has important political implications in view of the church's special position in Polish society. About 90 percent of Poles are Catholics -- and thus the primate's pronouncements help determine their attitude toward the authorities.

As dusk fell, the cardinal's coffin was carried through the streets of Warsaw to the seminary church where it will lie in state until the funeral Sunday. Thousands of Poles lined the route despite a steady drizzle, singing religious hymns as the procession passed. The cardinal died on the Feast of the Ascension, a major Catholic holiday.

It was a strange mixture of the simple and the grandiose. At the head of the procession were members of the cardinal's household and his family. Then came monks, priests and bishops of the church in their elaborate robes carrying umbrellas.

The state authorities, in cooperation with the church, order a four-day period of mourning to last until Sunday.

Among the messages of condolence that poured into the primate's palace were ones from Poland's Communist Party leader Stanislaw Kania and the premier, Gen. Wojciech Jaruzelski. The decision has been taken to grant Wyszynski full state honors at death, even if he frequently came into conflict with the state during his lifetime.

Announcing the cardinal's death, the official Polish news agency PAP described him as "the duke of the church, a great Pole and patriot whose beacon was the motto that to know how to unite and not to break apart is the supreme virtue."

The official obituary glossed over the primate's stormy relationship with the communist authorities -- and particularly the three years in the early 1950s when he was virtually under house arrest for refusing to compromise on the issue of the church's independence.

This period of Wyszynski's career was, however, emphasized by Solidarity, which said that, during Stalinist times, the church was the only place where Poles were able to learn the truth and be aware of the nation's Christian traditions.

Referring to last summer's strikes, the Solidarity statement said: "The cardinal must be credited with formulating the great program of moral renewal for the nation long before the August events. Solidarity has a special debt of gratitude to him. His voice helped and strengthened us in the most difficult moments. It will always remain alive for us."

After the announcement of the cardinal's death, state radio and television switched to serious music and flags were lowered to half-staff.

At Cardinal Wyszynski's residence, mourners were reminded of his long ecclesiastical career by the personal mementos from five popes that hung in the reception rooms. Among the first to pay thier condolences was a Solidarity delegation whose members placed a large red and white trade-union banner by the side of the coffin.

Another early visitor was Cardinal Franciszek Macharski, who takes over as acting head of the Polish episcopate until a successor to Cardinal Wyszynski is elected. A church spokesman said the election process, which will raise delicate issues of church-state relations, could take up to two months.

Under present rules, the bishop's conference is required to suggest three candidates for primate -- any or all of whom can be vetoed by the authorities. In practice, however, the church is unlikely to agree to what amounts to state interference in the election.

A number of church figures are regarded as possible successors. Macharski, 53, who succeeded the pope as archbishop of Krakow, is a brilliant theologian -- but lacks Wyszynski's charisma and authority.

Other possible candidates include Archbishop Jerzy Stroba of Oznan, 61; Bishop Branislaw Dabrowski, 63, who is secretary of the Polish episcopate; Wroclaw Bishop Henryk Gulbinowicz, 52; and Bishop Jozef Glemp of Olsztzyn, 52.

A younger candidate, still in his forties, is Abbot Jozef Tischner, who is a favorite of Catholic intellectuals. He is known as an outstanding speaker and philosopher closely connected with the independent church weekly, Tygodnik Powszechny.

Church sources say that someone like Bishop Dabrowski, who has been in charge of day-to-day negotiations with the government, would probably prove more flexible than one of the younger prelates such as Tischner, who favors a tough stand.

One possible solution would be for the triple function performed by Wyszynski to be divided between two or three men. He was archbishop of the ancient see of Gniezno (and thus ex-officio primate of Poland), archbishop of Warsaw, and chairman of the Polish episcopate.

Meanwhile fresh evidence of a deep split in the Communist Party emerged as a youth paper printed contrasting statements from two party meetings in southern Poland. One, signed by an unidentified "party forum" in the industrial city of Katowice, accused the moderate party leadership of indecisiveness and lack of determination in countering "antisocialist forces."

The statement said the party had lost direction and that the mass media had been taken over by antiparty centers openly pronouncing "right-wing opportunist views."

The hard-line opinions expressed in the statement were sharply criticized by party members in neighboring Krakow Province who described them as "large-scale subversion negating everything authentic and precious" in the reform movement.