Luca Traini embarked on his two-hour assault in February, following the sordid murder of a young Italian woman allegedly at the hands of Nigerian drug dealers.
Pamela Mastropietro's body was found dismembered and stuffed into suitcases days before Traini's attack.
The two incidents, which occurred at the height of Italy's tense electoral campaign, shook the country and laid bare deep tensions surrounding immigration.
Pro-migrant demonstrations across Italy condemning the shooting were in contrast to an outpouring of support for Traini who received messages of solidarity for his actions. Controversially, no politician paid a visit to his victims in hospital.
Traini, who was charged with attempted murder and racial hatred, would appeal, his legal team said, claiming the wounds suffered by the injured Africans showed he had not shot to kill.
He offered an apology to the wounded, five of whom were in court.
“I would like to apologise for what I did,” Traini reportedly said. “In prison I have understood that there is no difference between blacks and whites.”
During questioning, he had told police: “I wanted to hit the dealers, like those who sold drugs to Pamela.
“It's not my fault if in Macerata all the dealers are black,” he added.
The former security guard admitted to the shooting but rejected allegations the attack was racially-motivated.
His defence team had provided a psychiatric report which stated that Traini suffered from a personality disorder and that he was not completely aware of his actions at the time of the attack.
Traini surrendered to police draped in an Italian flag.