Henriette Reker, a independent close to the ruling Christian Democrats (CDU) of Chancellor Angela Merkel, was attacked by a 44-year-old man police said.
The attacker told police he stabbed Ms Reker "because of anti-foreigner motives," senior police investigator Norbert Wagner said.
The suspect appeared to have acted alone and had no police record, Mr Wagner added.
Four other people were hurt in the same incident but their condition was not known.
CDU regional chairman Bernd Petelkau told local media she had been stabbed in the stomach, while other reports said she had been injured in the neck.
Justice Minister Heiko Maas dubbed the attack "an unimaginable and abominable act" while regional president Annelore Kraft saw it as an "assault on democracy."
Reker is seen as standing a good chance of securing the mayorship Sunday in Cologne, Germany's fourth-largest city with 980,000 inhabitants.
Story continues below…
The attack came as Germany struggles to cope with a huge influx of asylum seekers, whose numbers are expected to reach between 800,000 and a million by the year's end.
Merkel's open-door policy has provoked a backlash among her conservative allies and sparked protests among the far-right.