Pawel Adamowicz was attacked with a sharp tool during the fundraising finale organized by the Great Orchestra of Christmas Charity.
Polish President Andrzej Duda said he had been informed that "doctors succeeded in restarting the heart of the seriously injured Mayor Pawel Adamowicz and there is hope, but his condition is very difficult." He called for people to pray for the mayor.
Paramedics resuscitated Adamowicz at the scene before rushing him to hospital where doctors said early Monday he had survived a five-hour operation but was in a "very, very critical condition".
The country's interior minister, Joachim Brudzinski called the stabbing "an act of inexplicable barbarity."
Broadcaster TVN24 says a suspect was detained. Other Polish media reported that a knife was used in the attack.
Police said the suspect was a 27-year-old with a criminal record and had previously carried out bank robberies. A police spokesman, Mariusz Ciarka, said the attacker gained access to the area using a media badge.
Read more: Huawei fires employee arrested in Poland on spying charges
Polish broadcaster TVN reported the assailant shouted from the stage that he was imprisoned under the government of Civic Platform, a party to which the mayor formerly belonged.
Peers send their prayersEuropean Council President Donald Tusk, a former Polish prime minister who co-founded Civil Platform and is from Gdansk, wrote on Twitter: "Let's all pray for Mayor Adamowicz. Pawel, we are with you."
Polish President Andrzej Duda tweeted that while he and the mayor have had political differences, "today I am unconditionally with him and his loved ones, just as — I hope — all of us compatriots are. I pray for his return to health and full strength."
Read more: Iran summons Polish top envoy over US summit
Adamowicz has been mayor of Gdansk, a Baltic port city, since 1998. He was part of the democratic opposition that originated in the city under the leadership of Lech Walesa during the 1980s.
As mayor, he is seen as a progressive voice and has supported LGBT rights and tolerance for minorities. He showed solidarity with the Jewish community when the city's synagogue had its windows broken last year, strongly denouncing the vandalism.
mm/jm (AFP, AP)
Each evening at 1830 UTC, DW's editors send out a selection of the day's hard news and quality feature journalism. You can sign up to receive it directly here.