Ex-Solidarity leader Lech Walesa had become a problem in the church-state dialogue after his release from detention late last year, officials say. The labor leader's personality and symbolic value were seen as an obstacle to an agreement.

Laszlo Cardinal Lekai, Roman Catholic primate of Hungary, had accused the Polish church of nourishing illusions and urged it to return to a step-by-step policy.

Such a policy was the hallmark of Polish primate Jozef Cardinal Glemp's predecessor, Stefan Cardinal Wyszynski, and was based on a continuing compromise with the communist regime to reinforce the church, but not at the cost of endangering a state in a crucial geopolitical position.

Cardinal Glemp's urging that Walesa be scuttled became more pressing after May 1, when the leader of the now-outlawed Solidarity union supported a call for street demonstrations and thousands of Poles turned out for them, despite the cardinal's appeal for moderation. This seriously jeopardized plans for the Pope's visit to Poland.

''In view of an understanding between the Polish state and the church, Walesa's charisma and exuberance are nothing but a destabilizing factor and would continuously undermine basic agreements,'' admits a prelate in the curia.

The prevailing view at the Vatican is that the union leader must withdraw from the political scene to make way for a church-state accord reached last week by the Pope and Poland's leader, Gen. Wojciech Jaruzelski.

Grounds of the agreement have not been officially announced.

Sources at the Vatican insist it is too early to speak of a compromise and are waiting for the lifting of martial law in Poland.

An article in a semiofficial Vatican newspaper proclaiming Walesa's political demise appeared just one day after the Pope returned from his eight-day visit. The unusually blunt commentary by the deputy editor of the authoritative L'Osservatore Romano, the Rev. Virgilio Levi, said, ''Officially, Lech Walesa passes once more from the scene. We can say that he has lost his battle.''

The implications contained in the article sparked such a controversy at the Vatican that Fr. Levi was forced to resign the following day. He admitted that he had expressed his ''own personal opinions,'' but no official denial was issued.

Levi, in fact, is very close to the Polish episcopate, particularly to Krakow's Franciszek Cardinal Macharski.

The Vatican journalist's suggestion that Walesa be relegated to the sidelines appears to have the stamp of authority.

''It is a fact that the Vatican wants the Polish government to lift martial law before it admits that any agreement or compromise has been reached,'' says a source close to the curia.

Reports circulating in Polish circles at the Vatican suggest its general lines include ending every form of discrimination against Roman Catholics' direct participation in the political process and allowing the church to have its own social organizations.

Polish churchmen are also demanding broader participation of Catholics at least at the local and municipal level in order to open up the structures of the state.

''Poland's delicate geopolitical position requires a cautious approach,'' a Polish member of the curia says.

The same caution is being followed on the problem of trade unions. Although the entire Polish episcopate recognizes the need for greater pluralism, it is still not clear what form it should take.

Sources have indicated that church officials favor fragmented union representation within factories to avoid the strong national structure promoted by Solidarity and rejected by the government.

A low profile approach also includes the church's request to form a bank of its own. That request was turned down by the government, but discussions have begun on formation of a church-run foundation whose organizational structure would not violate the state's economic dogma.

[The government has approved in principle plans for such a foundation to channel $2 billion in aid from the West to Polish farmers over the next five years, Reuters reports from Warsaw. Agriculture is traditionally the sector of the Polish economy that is closest to the Roman Catholic Church, and the state has failed to gain leverage in agriculture.]

''The Polish church has never been so strong,'' according to a Polish prelate.

But many observers at the Vatican see Fr. Levi's controversial article as a sign of a fear within the curia that the impatience of the Polish people could undermine the entire church-state dialogue.