Polish Communist Party chief Edward Gierek was ousted early today after reportedly suffering a heart attack. He was replaced by Stanislaw Kania, the former head of security and armed forces and a surprise choice by the party leadership following two months of labor turmoil.

The 67-year-old Gierek was said by the official press agency to have been hospitalized early yesterday after suffering "serious" heart trouble.

Following an unprecedented late-night session of the party Central Committee that ended about 1 this morning, the government announced that Gierek had been relieved of his job "because of a serious illness." It named Kania, 53, who is little known abroad, as the unamimous choice to succeed him.

Gierek has not been seen by the general public since Aug. 24 when he announced a major shakeup that forced the ouster of his close associate. Edward Babiuch, as premier and toppled nearly half of the Politburo. The changes left Gierek in weaker control of the state, and the prospect of his removal had been the subject of speculation for days.

The choice of Kania reflects the party's need to find a strongman to pull Poland together after an historic turn in the labor unrest with the acceptance of independent labor unions and promises of other major changes.

Although a shadowy figure in the ranks of the Politburo and not well known to the Polish public, Kania is said to have shown a great deal of realism in dealing with the labor crisis.

While he is not liberal, he seemed to act on the basis that the use of force would be disastrous for the party, and he kept Poland's police forces away from the strikers.

At the same time, the new party boss is sure to be well received by the Kremlin leadership.

Today's actions by the all-powerful Central Committee included elevation of two new members to the Politburo, the executive body of the Communist Party. They are Kazimierz Barcikowski and Andrzej Zabinski. Three others -- Zdzislaw Kurowski, Jerzy Wojtecki and Tadeusz Grabski -- were made secretaries.

These changes indicate party authorities still are intent on a moderate reformist line. The appointment of Barcikowski, who negotiated with workers in Szezecin Shipyard, is a victory for the moderates.

Zabinski called the democratization of the party at a special session of the parliament yesterday. He talked of the fact that in the last few weeks "the working class had sharply and angrily reminded us . . . that we paid too little attention to what it had to say."

At the same time, he stressed a line that is appreciated by party hard-liners, warning against the "escalation of demands" and adding that "antisocialist forces" could exploit the present crisis.

The choice of Grabski shows the leadership is aware of errors of the past. Grabski was fired in 1979 from the post of local party secretary in Konin after delivering an outspoken speech criticizing Gierek's leadership.

Pressures on Gierek had been intense during the summer strikes that crippled Poland's critical Baltic port and mining industries. Settlement with the workers, acceding to their prime demand for independent trade unions, provoked stinging Soviet criticism of what was seen as a departure from basic socialist principles.

The Soviet rebuke fueled speculation about Moscow's continued confidence in Gierek, and the stubborn strikes -- some still occurring -- called into question the extent of public confidence in him.

The first report of Gierek's illness came during a special session of the parliament, or Sejm called yesterday to introduce a broad range of legislation in line with the agreements signed with workers this week. Just before the official announcement, members of the Politburo at the session left the room.

At 7 p.m., the Polish radio reported: "Polish United Workers' Party First Secretary Edward Gierek developed serious disturbances in the action of the heart this morning. A medical council found his hospitalization indispensable. The patient is in a hospital under the solicitous care of specialists."

The statement was signed by five doctors said to be caring for him.

The circumstances of Gierek's illness strikingly resembled those leading up to the fall of his predecessor, Wladyslaw Gomulka. Bedridden by a stroke in December 1979 during a wave of violent worker strikes, Gomulka was asked to resign by members of the Politburo. Now 75, he lives on a pension in a Warsaw suburb.

Concern about Gierek's whereabouts began to stir at mid-morning when the party chief failed to attend the start of the parliamentary session.

The party leader usually attends parliament sessions, although the real power of the state is vested in the party Central Committee that he heads. Today's Central Committee was adjourned with an official statement that it would be reconvened later this month, presumably to attend to the analysis of the labor crisis it had been planning on conducting.

Speculation had been intense over whether Gierek would survive the latest session before it was called so suddenly. Last month's party purge had been seen as carving away much of Gierek's former strong standing.

While Gierek came to power a decade ago on a wave of popularity -- having proved himself a credible and sympathetic party boss in the southern mining region of Silesia -- public regard for him has dropped as his government has failed to deliver on initial promises of vastly improved economic life.

Adding to all this presumably was a personal sense of loss for Gierek at having a close friend and protege, Jaciej Szczepanski -- the former chairman of Polish television and radio who lost his job in last month's shakeup -- named Thursday as being under investigation by a Politburo commission on suspicion of embezzelment, misuse of government property and moral depravity.

In an opening address to yesterday's parliament session prior to the leadership change, Premier Jozef Pinwokski promised to honor the unprecedented agreements arrived at between the government and the nation's most powerful labor groups -- miners and shipyard workers.

"The society expects from the government that we will keep our word and thoroughly fulfill the committments, both economic and social, that were made public. I strongly declare that the government is fully aware of this and wishes to fulfill these commitments," Pinkowski said in his first public statement since being named premier following last month's shakeup.

He said the wage increases agreed to would be initiated in stages, and he pledged a freeze on meat prices for a year. It was an attempt to raise meat prices on July 1 that sparked the strikes.

Pinkowski took two initiatives beyond the strike agreements by proposing that workers take Saturdays off beginning in 1981, along with a shortening of the work week from 46 to 42.5 hours.

The premier also reaffirmed the government's promise to relax press censorship.

On the key issue -- the formation of free unions -- Pinkowski said, "Conditions will be created for the development of workers' self-management," but he avoided direct mention of the term "independent trade unions."

Although Pinkowski's address seemed to touch all the required notes, some observers noted it failed to reflect the feeling that the communist state has just gone through one of its most dramatic periods.

Saying the regime was moving "to satisfy the needs of the people," he indicated that the basic reforms could take a long time. "Deep analysis and appraisals are essential for this," Pinkowski said.

In contrast, the tone of the parliamentary debate that followed was assertive, demanding of change and questioning of past authority. One of the political questions to be considered in the post-strike era is whether parliament will play a more central role in decision-making.

"The parliament cannot be only a decoration," said Jan Szezepanski, a sociologist and non-party deputy. "Why is the role of parliament only to stamp decision?" he asked.

While it is unlikely that the party leadership will cede much new power to the parliament, it was reflective of the anticipation of change that such comments were made in a leadership body.

Workers in Poland's key industrial sectors have now returned to work following settlement with the last of the striking miners early yesterday morning. But there are continued official reports of strike activity in scattered locations.

"Unfortunately we are still encountering instances of strikes and work stoppages," Pinkowski stated. But the premier said "the present session of the parliament is taking place in an atmosphere of certain relaxation."

In Washington, the State Department had no comment on the change in the Polish party leadership.

Analysts in Washington familiar with the Polish political scene characterized Kania as a "faceless" bureaucrat, an establishment figure whose major work has been within the party apparatus, not the government.

["I wouldn't really expect any great innovations from Kania's leadership," said Richard T. Davies, a former U.S. ambassador to Poland. "I would expect rather that he'd be expected to try to preserve the status quo to the extent that this is possible" after the radical changes the party accepted to end the recent strikes -- in effect, to pull back somewhat from Poland's promise to give workers independent trade unions.]

Kania was responsible for the party's policy in the two key areas for Poland of security and relations with the Roman Catholic Church.

Kania, 53, was the son of a peasant and worked first as a blacksmith during World War II, according to his official biography. He joined the Communist Party in 1945 and attended party schools, heading the agriculture department in the early 1950s.

Joining the Central Committee as a deputy in 1964, he became a full member four years later.He studied economy in the committee's Higher School of Social Sciences at that time. He joined the Politburo five years ago.