Adamowicz, who has served as mayor of Gdańsk since 1998, was resuscitated at the scene and rushed to a nearby hospital where he underwent five hours of surgery. Doctors described his condition as “critical” and “serious”.

One of the surgeons, Dr Tomasz Stefaniak, said Adamowicz suffered a “serious wound to the heart, a wound to the diaphragm and to the internal organs” and had needed a huge amount of blood. Gdansk is holding a blood collection for Adamowicz on Monday and a rally against violence is also planned.

Adamowicz is a powerful liberal voice in a country that has been governed by the rightwing Law and Justice party since 2015. He is best known in Poland and internationally as a staunch supporter of LGBT rights and the rights of migrants and refugees during a period of rising anti-migrant sentiment. “I am a European so my nature is to be open,” Adamowicz told the Guardian in 2016. “Gdańsk is a port and must always be a refuge from the sea.”

Interior minister Joachim Brudziński described the incident as “an attack of inexplicable barbarity”. Polish president Andrzej Duda said: “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.”

“Shocked to hear of the attack on Paweł Adamowicz, Mayor of Gdańsk, this evening,” the mayor of London, Sadiq Khan, wrote on Twitter. “Sending best wishes for his swift recovery, and solidarity to the city he leads, his family and supporters.”

Polish media reports quoting police sources have named the alleged assailant as Stefan W, a 27-year-old from Gdańsk with a record of violent crime. Polish law restricts the surnames of people accused of a crime being reported.

Video footage of the incident shows the assailant addressing the crowd from a microphone on the stage. He is reported as saying: “Hello! Hello! My name is Stefan. I sat innocent in prison, I sat innocent in prison. Civic Platform tortured me, and that’s why Adamowicz is dead.”

Adamowicz was a member of Poland’s pro-European Civic Platform, which governed Poland between 2007 and 2015, before leaving the party to fight local elections as an independent. It is understood that Stefan W was convicted of a series of violent assaults and sentenced to prison in 2014.

An ambulance believed to be carrying the Gdańsk mayor, Paweł Adamowicz, to hospital. Photograph: Adam Warżawa/EPA

According to police sources quoted by Polish news broadcaster TVN24, the assailant is understood to have been planning the attack for some time.

The fact that the assailant was able not only to gain access to the stage and to attack the mayor but also to address the crowd in the aftermath has raised serious questions about security, which was provided by a private firm.

The attack happened during the culmination of the annual Great Orchestra of Christmas festivities, a nationwide charity drive for equipment to treat children in state-run hospitals. The charity has raised more than 951 million złoty (£200m) since it was founded 26 years ago. Concerts were being held for the charity across the country.