The mayor of a Polish city has undergone five hours of surgery after being stabbed on stage during the finale of a charity fundraiser, doctors have said.

Gdansk Mayor Pawel Adamowicz grabbed his stomach and collapsed in front of the audience at the Lights to Heaven fundraiser organised by the Great Orchestra of Christmas Charity, the country’s most important charity.

Doctors transported him to Medical University of Gdansk, where he underwent five hours of surgery, Dr Tomasz Stefaniak, one of the doctors treating Mr Adamowicz, said.

Almost seven hours after the assault, Dr Stefaniak told reporters early on Monday that “the patient is alive”, triggering applause, but added that the mayor remained “in a very serious condition”.

“The next hours will decide everything,” Dr Stefaniak said, appealing for thoughts and prayers for the popular mayor.

Poland Mayor AttackedGdansk mayor Pawel Adamowicz, right, speaks to an audience shortly before he was stabbed (Anna Rezulak/KFP/AP)

Polish media reported that a number of political officials and Gdansk Archbishop Slawoj Leszek Glod went to the hospital during the operation.

After the knife attack, the assailant shouted from the stage that he had been wrongly imprisoned under a previous national government led by Civic Platform, a party to which the mayor formerly belonged.

He said his name was Stefan and that “I was jailed but innocent… Civic Platform tortured me. That’s why Adamowicz just died.”

Police said the suspect was a 27-year-old with a criminal record.

A police spokesman, Mariusz Ciarka, said the attacker appeared to have mental health problems and gained access to the area with a media badge.

He was arrested and is under investigation.

TVN footage showed Mr Adamowicz on stage with a sparkler in hand telling the audience that it had been a “wonderful day” and then the attacker came toward him.

The mayor had been on the streets of his Baltic port city earlier in the day collecting money for the charity, along with volunteers around the country.

European 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.”

Mr Adamowicz, 53, has been mayor of Gdansk since 1998.

He was part of the democratic opposition born in that city under the leadership of Lech Walesa during the 1980s.

After leaving Civic Platform, he was re-elected to a sixth term as an independent candidate in the autumn.

“Horrified by the brutal attack on Gdansk mayor Pawel Adamowicz,” said Frans Timmermans, a Dutch politician and leading European Union official. “Hope and pray he will recover. A great leader of his city and a true humanitarian.”

The Great Orchestra of Christmas Charity raises money to buy state-of-the-art medical equipment for Poland’s cash-strapped state hospitals, mostly for children.