A law allowing people of the same sex to marry and adopt children came into force on 3 July 2005, making Spain only the third country in the world where gay marriage was legal at the time.
The law was passed on 30 June by the socialist PSOE government led by José Luis Rodríguez Zapatero. It came into effect just three days later.
One of the main activists behind the legalisation was the late Pedro Zerolo, a PSOE councillor in Madrid and his party's Secretary of Social Movements and NGO relations. He went on to marry his partner on 1 October 2005 and is considered an icon among the country's LGBT+ community. He died of cancer in 2015.
The 2005 Madrid Pride event took place over the same weekend as the law came into force. The party went down in history as one of the most important Pride celebrations in Spain.
The event traditionally takes place the first weekend after 28 June, World Pride Day, marking the anniversary of the Stonewall riots.
The law would guarantee same-sex married couples the same rights as heterosexual couples in terms of pension, inheritance, tax, residence and nationality as well as maternity and paternity leave.
The change of law would also guarantee the rights of minors living with same-sex couples, by giving them the same legal status as children adopted by heterosexual couples. It includes shared legal custody and protection on the death of a parent.
The right-wing Partido Popular (PP) and the Catholic Church were opposed to the law and the PP even challenged it in Spain's Constitutional Court. Demonstrations for and against the law took place throughout Spain around the time it was passed.
The first couple to get married under the new law were Carlos Baturín and Emilio Menéndez, then 57 and 50 respectively. They were married on 11 July in Madrid. They had been together for 30 years.
According to a recent survey, 83 per cent of Spaniards are in favour of gay marriage. However, only 74 per cent of those asked were in favour of same-sex couples adopting children.