SAN JUAN (Reuters) - Puerto Rico got its third governor in less than a week on Wednesday just hours after the bankrupt U.S. territory’s supreme court ruled that Pedro Pierluisi’s assumption of the office was unconstitutional and ordered him to leave.

The island’s justice secretary, Wanda Vazquez, was sworn in as governor at the supreme court in San Juan.

A unanimous decision by the nine-member high court nullified Pierluisi’s governorship based on the fact his earlier appointment as secretary of state and next in line for governor had not been confirmed by both chambers of the legislature.

Vazquez last week initially voiced reluctance to take over the island’s top government post after being targeted by protesters for alleged corruption and being too close to disgraced Governor Ricardo Rossello, who left office last Friday.

In a statement after becoming governor, Vazquez said: “I will continue to focus on putting (Puerto Rico) back on track in an orderly and peaceful way.”

The high court’s ruling followed weeks of political turmoil with Rossello resigning after of days of protests demanding he step down.

Offensive chat messages between Rossello and his closest allies and federal corruption charges against two former members of his administration sparked the protests, which drew around a third of the island’s 3.2 million people to the streets.

Slideshow ( 6 images )

More political changes could be coming as newspaper El Nuevo Dia, citing unnamed sources, reported on Wednesday that Jenniffer Gonzalez, Puerto Rico’s nonvoting representative in the U.S. Congress, could become the next secretary of state and eventual governor. The move has the blessing of legislative leaders, according to the report.

PIERLUISI LEAVES OFFICE

Pierluisi, who was given until 5 p.m. local time (2100 GMT) by the court to vacate the office, said he “must step aside and support” Vazquez.

“This is a time when we must all unite for Puerto Rico, leaving behind any partisan, ideological or personal agendas,” he said in a statement.

After agreeing to resign, Rossello on July 31 named Pierluisi, an attorney and the island’s former congressional representative, as secretary of state and his hand-picked successor.

The selection of Pierluisi was controversial mainly because he formerly gave legal advice to the island’s unpopular, federally created fiscal oversight board, which filed the government’s bankruptcy in 2017.

Slideshow ( 6 images )

Pierluisi was sworn in as governor last Friday following confirmation of his secretary of state appointment by only the Puerto Rico House of Representatives. On Sunday, Senate President Thomas Rivera Schatz filed a lawsuit claiming his chamber’s advice and consent duty under the island’s constitution was usurped and Pierluisi should be removed from office.

Pierluisi had argued that under a 2005 law, his appointment did not require confirmation because the legislature was not in session at the time.

But the court on Wednesday declared as unconstitutional the part of the law that allowed Pierluisi to be in a position to take over as governor without Senate confirmation.

The political uncertainty comes at a critical time in Puerto Rico’s bankruptcy and as it seeks billions of dollars in federal funding for healthcare and recovery efforts from devastating 2017 hurricanes.

In a statement following the court ruling, Puerto Rico’s U.S. congressional representative, Gonzalez, said it is “important to restore credibility in Washington by showing that we are able to govern ourselves according to our own constitution.”