Yes, in Spain is has been legal since 2005. Spain was one of the first countries in Europe to legalize gay marriage and the third in the world by that time.
Very proud of my country in that respect:
https://en.wikipedia.org/wiki/Same-sex_marriage_in_Spain