Mr. Adamowicz, 53, has been mayor of Gdansk since 1998 and was re-elected as an independent in November elections that underscored a deep divide between Poland’s liberal cities and conservative countryside. He has advocated gay rights and tolerance for minorities, and expressed solidarity with the city’s Jewish community last year when a synagogue’s windows were broken.

The A.P. quoted the police as saying the suspect in the knife attack was a 27-year-old with apparent mental problems who had previously carried out bank robberies, and that he had gained access to the area where Mr. Adamowicz was speaking with a media badge.

Mr. Adamowicz was brought to the Medical University of Gdansk for surgery after the attack. The A.P. quoted Dr. Tomasz Stefaniak, a doctor at the hospital, as saying early on Monday morning that Mr. Adamowicz was alive but remained “in a very serious condition.”

In a Twitter post on Sunday night, Sadiq Khan, the mayor of London, condemned the attack on Mr. Adamowicz and expressed solidarity “with the city he leads, his family and supporters.”