Territory to legalise same-sex marriage