The judge took the decision to shelve the case after hearing the suspects' version of events and seeing mobile phone footage of the event shot by one of the young men, local daily La Opinión de Málaga reported on Wednesday.
The lawyer working for the five youths — two of who were just 17 — said he would now take action against the woman for allegedly making a false accusation of rape.
The men were initially arrested after local police on Sunday morning found a young woman crying at the Malaga fairground.
She claimed to have been raped, but suspects have since told Spanish television stations that the sex was consensual.
After the incident, Francisco de la Torre, mayor of the southern Spanish city, was criticized for playing down the importance of the alleged crime by stating "there are more than a thousand rapes every year in Spain" and "let’s not give the impression that Malaga is unsafe".
Story continues below…
The incident also comes during a week in which the Spanish government has come under fire for its anti-rape guidelines, which included advice such as telling women to close their curtains to thwart peeping toms.
"It’s a form of scaremongering, it puts the blame on women and it stops them from taking responsibility," tweeted Socialist Party equality spokeswoman Carmen Montón about the ruling party’s anti-rape advice sheet.