Officials have also been ordered to respect the rights of same-sex couples.