The First Circuit Court of Appeals on Thursday threw out a district court judge's ruling upholding Puerto Rico's ban on gay marriage.

“The district court's ruling errs in so many respects that it is hard to know where to begin,” the court wrote.

Last month, U.S. District Court Judge Juan Perez-Gimenez ruled that the Supreme Court's June finding in Obergefell v. Hodges that gay couples have a constitutional right to marry does not apply to Puerto Rico because it is an unincorporated territory.

(Related: Federal judge says gay marriage ruling does not apply to Puerto Rico.)

Perez-Gimenez first upheld Puerto Rico's ban in 2014. In sending the case back to the lower court, the First Circuit wrote: “Upon consideration of the parties' Joint Response Pursuant to Court Order filed June 26, 2015, we vacate the district court's Judgment in this case and remand the matter for further consideration in light of Obergefell. … We agree with the parities' joint position that the ban is unconstitutional. Mandate to issue forthwith.”

The appeals court took issue with Perez-Gimenez's ruling, saying that he had “directly contradicted our mandate,” and kicked him off the case, ordering that the case be assigned randomly to a different judge.