Paramedics resuscitated Pawel Adamowicz, 53, at the scene before taking him to hospital.
A doctor working for the regional authorities, Jerzy Karpinski, described the mayor's condition as "very serious".
A video recording of the attack posted on YouTube showed the attacker bursting onto the podium.
After knifing the mayor, he seized the microphone and claimed to have been wrongly jailed by the previous centrist government of the Civic Platform (PO) and tortured.
"That's why Adamowicz dies," the attacker said.
The Civic Platform had supported Adamowicz's re-election in 2018 municipal elections.
Adamowicz later underwent surgery, deputy mayor Piotry Grzelak, was quoted as saying by the PAP news agency.
The attack took place on the podium at a fundraiser for the purchase of medical equipment.
The attacker was quickly apprehended by security guards and arrested by police.
A Gdansk police spokesman said the detained man was a 27-year-old who lived in the city EU President Donald Tusk, Poland's President Andrzej Duda and Prime Minister Mateusz Morawiecki immediately expressed their concern and support for Adamowicz.
"The attack on the life and health of the mayor of Gdansk must be firmly condemned," Morawiecki said on Twitter.
"Despite differences in political opinion, I am unconditionally with him and his relatives.... I pray for his health and recovery," Duda added on Twitter.
Interior Minister Joachim Brudzinski condemned the attack as "an incomprehensible act of barbarism". (AFP) SMJ
(This story has not been edited by Devdiscourse staff and is auto-generated from a syndicated feed.)