Hundreds of demonstrators gathered under a heavy police presence in the capital city's central Puerta del Sol square, calling for the 32-year-old rapper Pablo Hasel to be released and wielding banners reading “enough censorship”.
Masked protesters threw bottles at police, who charged at them in clashes that lasted for several hours, AFP journalists said.
Madrid police said 14 people were detained, with emergency services reporting that nine people were slightly injured in the altercations.
The city's conservative mayor Jose Luis Martinez-Almeida condemned the incidents, tweeting: “The violent and those who do not accept the rules have no place in our society.”
In Barcelona there were altercations between officers and protesters following heavy clashes on Tuesday night, with demonstrators lobbing objects at police and setting homemade barricades ablaze.
Officers responded by using foam bullets and charging the rallies, with the police later tweeting that 29 people had been detained.
There were violent protests reported in Lleida – the rapper's hometown, and where he was arrested – as well as in the towns of Gerona and Tarragona, Catalonia police Mossos d'Esquadra also tweeted.
It follows the arrest of at least 15 people after violent rallies in Barcelona and other cities in the northern Catalonia region on Tuesday.
Tuesday night's unrest left more than 30 people injured, including 19 police officers, according to local authorities. It follows police storming a university campus in the Catalan city of Lleida to arrest Hasel.
Protesters in Barcelona. Image: Josep Lago / AFP
“They will never make us give in, despite the repression,” he shouted after he was escorted out of the facility where he had been holed up. “It is the fascist state that is arresting me. Death to the fascist state!”
Hasel missed a deadline last Friday to give himself up to police and begin serving a nine-month jail term handed down in 2018.
'Unjust and disproportionate'
At issue was a series of tweets calling former king Juan Carlos I a mafia boss and accusing police of torturing and killing demonstrators and migrants.
Hasel is known for his hard-left views, but his case has become a cause celebre among campaigners who say that prosecuting him is a dangerous assault on free speech.
His sentence caused outrage in Spain, with stars including the film-maker Pedro Almodovar and the Hollywood actor Javier Bardem expressing support for his cause.
Amnesty International denounced the move saying jailing the rapper for song lyrics and tweets was “unjust and disproportionate”.
The Socialist-led government has announced it is seeking to make free speech laws less restrictive, with Podemos, the junior partner in the coalition, saying Tuesday that it would request a pardon for the rapper.
Hasel's case echoes that of another rapper, Valtonyc, who fled to Belgium in 2018 after being convicted of similar crimes. Spain wants him extradited but Belgium has refused as his offences are not a crime under Belgian law.
Valtonyc told AFP he felt “shame” and “anger at seeing a colleague treated like this for doing what artists do, which is to provoke”.