A state court in Duesseldorf found 45-year-old, Frank S, tried to kill Henriette Reker for her welcoming stance to refugees.
The attack came in October last year at the height of Germany's refugee influx while Ms Reker was head of refugee housing in Cologne.
It left Ms Reker seriously injured.
Barbara Havliza, the presiding judge at Duesseldorf state court said: "He wanted to send a signal against the government's refugee policy. He wanted to create a climate of fear and influence politics.''
"He believed that the German government was not entitled to let refugees into the country,'' the judge added.
The defendant, a German national, admitted to the attack during the two month trial but denied he tried to kill Ms Reker.
In her testimony Ms Reker said she was "very worried that I could be paralysed'' and that she still suffered from nightmares. She was put in an induced coma after the attack and took over as mayor a month later.
The defendant, an unemployed house painter testified about his participation in right-wing groups in Bonn in the 1990s. He has not been named in line with German privacy laws.
He said he was a "rebel with conservative values" and that he was motivated by Chancellor Merkel's "wrong policy" of granting asylum to thousands of refugees.
Germany received over 476,000 asylum applications in 2015, with 1.1 million arrivals in total.
New Years' celebrations in Cologne earlier this year saw many women reporting sexual assaults, allegedly by men of North African and Arab appearance.
A man who stabbed the Mayor of Cologne in the neck a day before she was elected has been convicted of attempted murder and jailed for 14 years.