A German court Friday handed a 14-year jail sentence to a man for stabbing Cologne's future mayor in the neck in a violent protest against her welcoming stance towards refugees.

In a case that shocked the country at the height of last year's refugee influx, the defendant, identified only as Frank S., 45, admitted during the two-month trial to attacking Henriette Reker on the eve of her election in the western city in October.

The unemployed house painter has been in custody since he was arrested at the scene.

‘The defendant is guilty of attempted murder and causing grievous bodily harm’, said presiding judge Barbara Havliza in the neighbouring city of Duesseldorf.

The sentence fell short of the life imprisonment demanded by the prosecution.

At the opening of his trial in April, the defendant detailed his participation in the right-wing scene in the nearby city of Bonn in the 1990s and described himself as a ‘rebel with conservative values,’ but denied being a neo-Nazi or wanting to kill Reker.

However, he testified that his actions were motivated by the ‘wrong policy’ of Chancellor Angela Merkel's government to take in large numbers of refugees.

Reker, who was previously in charge of running refugee services in Cologne, was attacked while she was campaigning at a market square.

She subsequently won the local elections while recovering from her wounds in hospital.

The assault stunned Germany at a time of growing division over the government's decision to open its doors to people fleeing war and misery, with more than one million arrivals last year alone.