The clashes on Thursday evening in Lavapies, a district in the centre of the Spanish capital with a large immigrant population, saw angry protesters set fire to dustbins and motorbikes, and throw stones at riot police.
A police spokesman said six Spanish people had been arrested, including a minor and a woman.
He added 10 police officers were injured in the unrest, while emergency services said four people were slightly hurt in the protest.
Demonstrators at the time told AFP they were protesting in support of Mame Mbaye.
Mbaye was a street vendor in his mid-thirties from Senegal, who arrived in Spain by boat 12 years ago.
Emergency services said he was found unconscious on a street in Lavapies by police on patrol.
"They were busy trying to revive him" when emergency workers arrived, a spokeswoman said. However he died of cardiac arrest.
She did not know what had happened to Mbaye before he collapsed, but several other street vendors who were with him said he had been chased by police from the central Puerta del Sol square.
"Municipal police arrived and chased him from Sol to Lavapies with a motorbike," said Modou, a 25-year-old vendor from Senegal who refused to give his surname.
Street vendors are a fixture of Madrid, and are often seen laying out items like perfume or hats on white sheets, which they can quickly pick up and take away when the police arrives.
While illegal, the trade is often the only way to make money for migrants struggling to find other employment.
Mbaye "had arrived by boat, he was unemployed which is why he worked as a street vendor, and he helped his family in Senegal," said Modou.
He was one of thousands of migrants who have reached Spain over the years in search of a better life.
Spain is the third busiest gateway for migrants coming to Europe, with close to 23,000 arrivals in 2017. Hundreds have died along the way.