Puerto Rico's Supreme Court ruled unanimously on Wednesday that Pedro Pierluisi was unconstitutionally sworn in as governor last Friday.

The court has ordered Pierluisi to resign by 5 p.m. Wednesday.

Judge Rafael Martinez Torres said a 2005 legislative amendment to Law 7 — which allows only one chamber of Puerto Rico's Congress to unilaterally approve the secretary of state becoming governor — violates the commonwealth's constitution.

As a result, the Supreme Court voided Perluisi's swearing-in because he was not previously confirmed as secretary of state by both Puerto Rico's Senate and House. Only the House of Representatives weighed in.

Pierluisi was nominated as secretary of state by former Gov. Ricardo Rosselló, who resigned last Friday amid public protests and a scandal over a thread of homophobic and misogynistic texts.

The island's constitution calls for the secretary of state to be the first in the line of gubernatorial succession. The next person in the constitutional line of succession is Secretary of Justice Wanda Vazquez. She has previously stated she does not want to be governor.

Copyright 2019 NPR. To see more, visit https://www.npr.org.