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.
HAVE YOUR SAY The Vatican probably saw him as a safe pair of hands but now don't want their own fingers burnt.
David Scheinmann, Cardiff, UK
Send us your comments
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.
St. John's Cathedral, where the former Archbishop announced his resingation

Stanislaw Wielgus, the Archbishop of Warsaw, resigned yesterday after admitting to have worked for the secret police of Poland during the operation of the Communist government. At a mass in Warsaw Cathedral, the Archbishop was to have marked his formal installation. Instead, he tendered his resignation. The resignation came at the request of Pope Benedict XVI, who had appointed Wielgus one month previously. 

The reaction to the resignation is mixed. Polish President Lech Kaczyński, who attended the service, applauded the resignation. Wielgus' supporters gathered outside the cathedral, yelling "Stay with us". Those opposed to the Archbishop also gathered outside, carrying banners that said "non possumus" ("we cannot allow that").

Since the late 1960s, the former Archbishop spied on members of the Church for about 20 years. After the ''Gazeta Polska'' newspaper published allegations of his actions on December 20, Wielgus denied them. However, when church officials announced they had obtained documents showing that Wielgus had willingly co-operated with the secret services, he acknowledged that the accusations were true. 
There is some suspicion that the documents were leaked by communists, in retribution for the Catholic Church's role in the fall of European communism.

A poll, conducted by the TNS OBOP Institute and published January 5 in the Polish daily ''Dziennik Polska-Europa-Świat'', revealed that 26% supported the Archbishop's immediate resignation, 41% thought that he would have to resign "after some explanations", 20% believed that he should keep his position, and 13% had "no opinion".

Cardinal Józef Glemp will retain the position of apostolic administrator until a replacement is chosen.