Poland's Roman Catholic primate, Cardinal Josef Glemp, attacked Marxism today as "based on the notion of force" and said Catholics have reasons not to cooperate with a communist government.

In a forceful sermon before tens of thousands of Poles celebrating a national Catholic anniversary in the town of Czestochowa, Glemp defended the church from charges of meddling in national politics and criticized government controls over education, the media and religious life.

He sketched a blunt picture of "the frictions between religion and the system of materialist ideology" and said Poland's communist leadership "postpones the final confrontation" with the church only as "a strategy . . . caused by circumstance and not good will."

The statement was one of Glemp's strongest defenses of the role of religion in Poland since he became primate in 1981.

Delivered before a crowd estimated at more than 200,000, the sermon marked the anniversary of the shrine devoted to the painting of the Black Madonna, Poland's most sacred religious icon.

The primate offered an implicit rebuff to efforts by the government of Gen. Wojciech Jaruzelski to rally public support as it prepares for parliamentary elections in October.

Government authorities have sought to win the cooperation of the church in persuading Poles to vote in the elections despite a call for a boycott by the underground leadership of the banned trade union Solidarity.

Glemp, however, appeared today to justify what he called "resistance among Catholics" to "serving the homeland."

"How can one build the future when there are efforts to erase from it the values that are most important, those connected with belief in God?" he asked.

"The believer who is to build the future of the atheistic homeland feels like somebody who is cutting the tree he is sitting on out from under him for the good of some branch that grows from the side."

Glemp did not mention the elections directly but said that "religion in Poland is so widespread that the believers should be included in the political life of the country."

In contrast, the Polish primate said Marxism "is based not on the force of thoughts but on the notion of force."

The primate's statement came two months after a rare meeting with Jaruzelski that both government and church officials hoped would improve strained church-state relations. Glemp's remarks suggested that tensions nevertheless have increased with the approach of the elections, now the principal focus of government policies.

Government authorities were disappointed earlier this summer when the High Council of the Catholic Episcopate considered and then rejected a proposal under which 25 Catholic lay activists would have been named to the government list of candidates for the Polish parliament, communist party and church sources said.

Since then, articles have appeared in the state-controlled press criticizing church involvement in politics and suggesting the church was being used by government political opponents.

For their part, church authorities have been frustrated by the lack of government steps to sanction a proposed church-sponsored agricultural fund.

Jaruzelski pledged support for the initiative during the meeting with Glemp, church sources said.

Glemp, who used a sermon last April to express irritation with official press attacks, singled out negative media commentary again today and insisted that references to "the alleged sneaking of the church into political life" were "unfair."

"We as priests are not rushing to tribunes. We are not joining marches or parades. We don't put forward our chests for medals but remember that our prize is God."

"The church sees its social service as morally appraising the social behavior of individuals and groups," Glemp said. "It also participates in a dialogue that concerns important issues of national life. One has to admit honestly that the voice is carefully listened to."

He said that while the church showed tolerance toward nonbelievers, "the object of government tolerance appears not to be a human being with his values but some abstract principle of secularism."

In schools, he said, "society knows that the educational line will be imposed from above, that the society cannot in a legal way direct the education."

"Are we talking about tolerance," Glemp asked, "or rather the respecting of soulless regulations?"