"The streets are ours at night as well," read a large banner carried by the demonstrators as they made their way from the equality ministry to the Supreme Court.
"Even alone and drunk, I want to get home," the crowd chanted. Organisers said some 50,000 people took part in the protest, the latest in a strong of demonstrations held across Spain since a court in the northern
city of Pamplona on April 26 issued its ruling.
The five men, in their late twenties, had been accused of raping a woman, then 18, at the entrance to an apartment building in Pamplona on July 7, 2016, at the start of the week-long San Fermin bull running festival, which draws tens of thousands of visitors.
They took a video of the incident with their smartphones and then bragged about it on a WhatsApp messaging group where they referred to themselves as "La Manada" ("The Pack").
The men were acquitted of sexual assault, which includes rape, but sentenced to nine years for the lesser offence of sexual abuse, which under Spanish law implies there was no violence or intimidation.
One of the three judges had argued that the men should be completely acquitted.
"This ruling about 'the pack' was the drop that caused the cup to spill over" with indignation, Ana Carbajo, a 61-year-old psychologist, told AFP at the protest.
"We live in a society that is formally egalitarian, but it's only formal," added Carbajo, who was dressed in purple, the traditional colour of feminism.
"We thought that gender inequalities would decrease but they persist, with the difference in wages or the now unbearable theme of violence that we are no longer willing to tolerate."
Last year 49 women were killed in Spain by their partner or a former partner, five more than in 2016, according to government figures.
On Saturday 32,000-35,000 people took part in a demonstration against the court ruling in Pamplona itself, rallying under the slogan "it's not sexual abuse, it's rape".
The angry backlash against the verdict follows the wave of feminist protest movements around the world sparked by the #Metoo campaign against sexual harassment and assault.
"What is most shocking is that one of the judges came out saying that he wanted the five to be fully acquitted," said Sara Mosquera, a 20-year-old student.
She carried a sign that read: "There will always be packs if we protect the wolves".
Change to laws?
Defence lawyers had argued the victim agreed to the sexual encounter and would only acknowledge the gang had stolen a phone from the girl, who was left half naked in the building entrance.
Lawyers for the woman and attorneys for the men have said they will appeal. The Spanish government has said it will consider reforming the country's rape laws.
Friday's demonstrators passed by Madrid city hall, which since 2015 has been occupied by a former judge turned mayor, Manuela Carmena, who has said the court's ruling in the case "does not meet women's demand for justice."
A petition asking for the three magistrates in the case to be dismissed has garnered over 1.3 million signatures.
Spanish women have also started recounting their experiences of sexual assault on social networks with the hashtag #Cuentalo, or "Say it" in English.
By Laurence Boutreux