A provincial parliament in Australia has become the country's first to pass a law that allows same-sex marriages. But the federal government has threatened a court challenge.

The Australian Capital Territory parliament passed the law with the support of lawmakers from the province's governing Labor and Greens parties. All eight opposition Liberal Party lawmakers in the 17-seat Legislative Assembly voted against the bill.

The first gay marriage could take place in December, but federal Attorney General George Brandis, a member of the Liberal Party, said his government has legal advice that the legislation is invalid.

Australian Capital Territory Chief Minister Katy Gallagher has refused a request from Brandis not to allow same-sex marriages to take place until the High Court ruled on the law's constitutional validity.