The recently-appointed Archbishop of Warsaw who has been at the centre of a communist era spying row was right to resign, the Vatican has said.
Wielgus (L) was moved to tears during the service
It said revelations about Stanislaw Wielgus's co-operation with the Polish secret police under communist rule had compromised his authority.
He confirmed his decision in a tearful announcement to the congregation gathered to witness his installation.
The BBC's David Willey in Rome says the resignation is a setback for the Pope.
The sudden announcement of the Pope's acceptance of Monsignor Wielgus's resignation came only two days after an official statement had reiterated that the prelate enjoyed the pontiff's full confidence.
The Vatican has suggested the disclosures - published first in the media and later confirmed by the archbishop himself - may have been leaked by communists in revenge for the Catholic Church's role in their fall from power.
Applause and shouting
The decision by the 67-year-old Polish prelate was made public less than an hour before the beginning of a Mass which was to inaugurate his appointment at St John's Cathedral in the city.
His confirmation of the news prompted some in the congregation to applaud, including the anti-communist President, Lech Kaczynski, while others shouted for him to stay.
The Mass went ahead, but focused on giving thanks for the outgoing archbishop, Jozef Glemp, who will now administer the diocese on a temporary basis. He said Monsignor Wielgus should not be judged too harshly.
Correspondents say the episode is an unprecedented embarrassment for the Catholic Church in Poland.
Monsignor Wielgus had been under severe pressure since he admitted that not only had he collaborated, but that he had lied about it, even after the allegations surfaced last month.
The Church plays a very prominent role in Polish society, and was highly esteemed because of its leading role in the fight against communism in Poland and worldwide, particularly during the time of Polish Pope John Paul II.
But historians estimate that up to 15% of Polish clergy agreed to inform on their colleagues in the communist era.
The Polish Church has launched a series of investigations in recent years to identify collaborators.
Series of problems
Pope Benedict XVI made no mention of the crisis in the Polish church in his regular Sunday speech to pilgrims in St Peter's Square, despite the presence in Rome of a large group of Polish pilgrims.
Our Rome correspondent says the Vatican clearly realised that Monsignor Wielgus's position had become untenable after he admitted spying for the communists from the 1970s onwards, and accepted the inevitable.
He adds that the crisis in Warsaw does mark yet another setback for the Pope, who last year had to deal with a series of international problems.
These included the Church's difficult relations with the Muslim world after the Pope's lecture at his former university in Germany linking Islam with violence, and continuing aftershocks in priestly paedophile scandals in various countries, in particular the United States.