Fifty-year-old Gianluca Casseri, who police described as a right-wing extremist, fired shots from a pistol in Dalmazia square, killing two Senegalese street vendors and seriously injuring another.
Casseri then drove to the San Lorenzo market where he opened fire again, wounding two other men, believed to be African migrant workers who were working at the market.
The gunman then fled before shooting himself in the throat, police said.
In a statement, Italian President Giorgio Napolitano condemned all forms of “racist violence and xenophobia”, calling the attacks “barbarous”.
“The heart of Florence is crying today,” Matteo Renzi, the city’s mayor, said in a Twitter message, declaring a day of mourning on Wednesday and pledging to repatriate the bodies to Senegal.
(Above eyewitness footage of the protests following the shooting)
Andrea Riccardi, Italy’s minister of international co-operation and integration, and a Senegalese imam will attend a ceremony at Florence city hall on Wednesday.
The shooting led to demonstrations involving 200 Senegalese people who marched through the city shouting “Shame!” and “Racists!”
Hundreds of immigrants were later seen praying on their knees in tears in front of Florence’s famous cathedral.
Casseri was the author of fantasy novels including The Key of Chaos, about a wizard, a mathematician and an alchemist, which enjoyed some popularity.
He also wrote an academic paper about Dracula folklore and was the editor of a magazine about fantasy and horror fiction and comics.