The top brass of Spain's ruling conservative Popular Party including Prime Minister Mariano Rajoy have attended the same-sex marriage of their deputy secretary-general, giving tacit approval to a law they once bitterly opposed.

Javier Maroto exchanged vows with Josema Rodriguez late Friday at a ceremony in the northern city of Vitoria attended by Rajoy, secretary-general Maria Dolores Cospedal and other party dignitaries, the party said in a statement.

"In Spain, the right to marriage is for everyone and we all share that message today," Maroto said afterward.

"Parties evolve," he added. "Now my party and the government join in backing that right."

Maroto and Rodriguez have been partners in a same-sex relationship for 19 years. Apart from being a senior leader in the Popular Party, Maroto is a former mayor of Vitoria.

Parliament legalized gay marriage in 2005 under a Socialist government, angering conservatives in once-staunchly Roman Catholic Spain. The Popular Party then challenged the law but Spain's Constitutional Court — the highest in the land — upheld its legality.

Now, a decade after voicing strong opposition to gay marriage, photographs at the ceremony that ended early Saturday showed Rajoy with other party leaders smiling broadly as they posed beside the two grooms.