Thousands of people witnessed the apparent assassination attempt on Pawel Adamowicz, 53, who was rushed to hospital where he underwent a five-hour long operation.
The attack took place during the finale of a children's hospital charity event, known as the Great Orchestra of Christmas, when Adamowicz was thanking everyone who had helped raise funds for medical equipment.
Video footage shows the attacker walking around the stage holding up a knife and saying to the crowd that he was imprisoned and tortured by the former government.
The 27-year-old suspect, who was arrested, is a Gdansk resident. He was previously convicted for bank robbery and has spent time in prison.
Asked about a motive, Gdansk city press officer Dariusz Wołodźko said the suspect came onstage shouting, and blamed the mayor and his party for his conviction and imprisonment.