An Italian man with extreme rightwing views has been sentenced to 12 years in prison for shooting and wounding six African migrants in a racially motivated attack in the central city of Macerata.

Luca Traini, 28, was arrested by police in the main square of the central city of Macerata after the rampage, which injured six immigrants and terrorised the city last February. The sentence included an aggravating circumstance of racial hatred.

Traini targeted black migrants as he drove around Macerata, hitting nationals from Ghana, Mali and Nigeria. He later abandoned his car and made a fascist salute, an Italian flag draped over his shoulders, as police arrested him.

No-one died in the attack and Traini apologised in court for his actions. “I am sorry for the injuries I caused,” he said. “While in prison, I have understood that the colour of ones’ skin has nothing to do with anything.”

The shootings came a month before national elections that were marked by furious debate over the influx of some 600,000 mainly African migrants into Italy since 2014.

The anti-immigration League emerged as the second-largest party in parliament at the vote and went on to forge a coalition government with the anti-establishment Five Star Movement. Northern League leader Matteo Salvini is the interior minister and has followed through on a campaign pledge to toughen migration laws.

Traini had been an unsuccessful candidate for the anti-immigrant Northern League party and had previously been associated with neo-fascist groups.

Traini launched his attack three days after the discovery of the body of teenager Pamela Mastropietro near Macerata. A Nigerian, Innocent Oseghale, has been charged with her rape, murder and dismemberment, as well as with drug dealing.

Oseghale says Mastropietro died of an overdose and denies killing her.

“I wanted justice for Pamela,” Traini told the court.