The bill means that survivors of rape no longer need to prove they suffered violence or were intimidated.
MPs in Spain have approved a new "only yes means yes" law that emphasizes getting explicit consent for sex.
Victims will no longer need to prove they have been intimidated or suffered violence in rape cases and the bill removes a distinction between the offences of "sexual aggression" (rape) and the lesser "sexual abuse".
It was proposed by the country's Socialist government after the high-profile "La Manada" ("Wolfpack") gang rape incident in Pamplona in 2016 prompted widespread protests.
Five men were found guilty of sexually abusing, but not raping, an unconscious 18-year-old woman because she could not prove she had not given consent.
Spain’s Supreme Court later overruled two lower courts and sentenced the five defendants to 15 years in prison for rape.
A total of 205 MPs voted in favour of the bill, while 141 lawmakers opposed it and three abstained from voting.
Lawmakers from the opposition conservative Popular Party and the far-right VOX party have argued that the bill lacks legal certainty or aims "not to protect women but to attack men".
The "only yes means yes" law was first approved by Spain's parliament in May before the country's Senate amended the bill.
Under the new law, "consent shall only be understood to exist when it has been freely manifested, through acts that, in view of the circumstances of the case, clearly express the will of the person".
The bill also provides more support to victims of sexual offences and measures to improve the prevention and detection of such cases.
Anyone who harasses someone in the street or forwards private images of another person without their consent will also be punished.
"Our country is finally enshrining in law that consent must be the central element of our sexual relationships," said Equality Minister Irene Montero.
"Women will no longer have to show that there was violence or intimidation in order for it to be recognised as sexual aggression."