The deputy editor of the semi-official Vatican newspaper was forced to resign today, hours after the publication of a front-page editorial suggesting that the Polish labor leader Lech Walesa was politically finished.

The resignation was announced by a Vatican spokesman who said that the editor, the Rev. Virgilio Levi, had been expressing his "own journalistic opinions" rather than the Roman Catholic Church's official view. The signed article appeared yesterday in L'Osservatore Romano, which is usually regarded as the authoritative voice of the Vatican.

Levi's article, and the embarrassed reaction of his church superiors, has strengthened speculation here that Pope John Paul II reached some kind of understanding with Poland's Communist leaders during his pilgrimage to his homeland this week. Polish government officials in Warsaw have said that the pope's eight-day visit could pave the way for an early lifting of martial law and an amnesty for political prisoners.

The Vatican's deputy spokesman, Pierfranco Pastore, did not quarrel with the theme of the newspaper article, which said that sometimes the "sacrifice of inconvenient individuals" was necessary to promote the well-being of the community. He said merely that Levi had resigned in view of certain "interpretations given to the article."

Meanwhile, Walesa was quoted by an American television reporter as saying yesterday that he had some "hard thinking" to do about his private talk Thursday with the pope at a mountain rest house.

The Polish-born pontiff received Walesa, leader of a workers' rebellion in August 1980 and later chairman of the now outlawed Solidarity independent trade union, the day after meeting for the second time during his visit with the country's military leader, Gen. Wojciech Jaruzelski.

Walesa, who has yet to reveal any details about his meeting with the pope, was quoted by NBC as saying: "The problem is not who negotiates but what is negotiated. . . . It's not important who solves problems. If there are better people, then let them go ahead."

In his article, which was headlined "Honor to the Sacrifice," Levi said that by receiving Walesa the pope had wished to give satisfaction to his people, for whom Walesa would always remain a symbol. But, he added, the meeting had taken place in secret in order not to damage "the delicate phase of national reconciliation that has begun with so much difficulty."

"Not everybody will be in agreement. In Poland, hardly anyone. And they will suffer on account of it. But there were reasons of force majeure," he said.

Official Polish newspapers carried brief extracts from the Vatican article today along with a comment that it had created considerable interest among foreign observers. Reached by telephone in Gdansk, Walesa refused to comment, but his wife, Danuta, described the article as "a provocation."

There is nothing the Communist authorities in Warsaw would like more than for the Vatican to declare that Walesa no longer has a political role. This would strengthen their argument that, as "the former leader of the former Solidarity," he is merely a private citizen and an unsuitable negotiating partner.

Poland's military rulers have said they are prepared to reach "agreement" with the Roman Catholic Church but not with what they call "the proven enemies of socialism," a category that includes Walesa.

It remains to be seen what concessions the government would be prepared to make. In addition to official hints that martial law will be lifted July 22, Poland's national day, there have been suggestions of an amnesty for Solidarity supporters convicted of crimes under martial law and a halt to political trials of dissident intellectuals.

The key point is whether the government will agree to the rebirth of an authentic independent trade union movement. Communist officials have spoken out firmly against allowing workers a free choice of trade unions even though this was an essential feature of the Gdansk agreement of 1980.

Vatican observers speculated that Levi might have been asked to resign because he undercut the church's negotiating position. The publication of his article before Walesa had made his own position clear could be viewed in Poland as a cynical tradeoff over the former Solidarity leader's head.

Although he has considerable knowledge of Poland and has visited the country several times, Levi did not accompany the pope here. He has been working for L'Osservatore Romano for 15 years and frequently writes articles reflecting the views of the church hierarchy.

In his article, which read like a political obituary, Levi wrote that Walesa "has lost his battle." He added, however, that history knew many examples of people who had been pushed to the margin but returned "as the authentic saviors of their people."