(CNN) Puerto Rico's Justice Secretary Wanda Vázquez Garced was sworn in Wednesday afternoon as the third governor that the financially and politically troubled island has had in less than a week.

Hours earlier, the highest court declared unconstitutional the governorship of disgraced former Gov. Ricardo Rosselló's handpicked successor, a move certain to prolong the political crisis on the US territory.

The unanimous decision by the Supreme Court threw out last week's swearing in of attorney Pedro Pierluisi on grounds he had not been confirmed as secretary of state by both chambers of the legislature.

Pierluisi, in a statement shortly before Vázquez took the oath, announced that his short-lived tenure had come to an end after just five days.

"In light of the decision by the Puerto Rico Supreme Court, I must step aside and support the Secretary of Justice of Puerto Rico," he said.

Pierluisi added, "This is a time when we must all unite for Puerto Rico, leaving behind any partisan, ideological or personal agendas. In other words, this is a time for unity of purpose for the benefit of Puerto Rico, until our people have the opportunity to choose their future leaders in next year's elections."

Moments after his statement, the governor's office tweeted a photo of Vázquez taking the oath of office.

Justice Secretary Wanda Vazquez is sworn in as governor of Puerto Rico by Supreme Court Justice Maite Oronoz in San Juan on Wednesday.

Pierluisi had been expected to replace the disgraced Rosselló, who stepped down as governor following weeks of protests. Rosselló named him Puerto Rico's secretary of state, placing him next in line to become governor.

But a legal challenge by Senate president Thomas Rivera Schatz, a Rosselló rival who himself has sights on the governorship, had asked island's highest court to intervene.

"To those who lent themselves, for their personal interest, to this embarrassing attempt to install an illegitimate government, that is how you will go down in the history of Puerto Rico," Rivera Schatz said in a statement posted on Facebook after the ruling.

Infighting within the New Progressive Party

Vázquez said Wednesday that she respected the ruling and would assume the governorship.

"Puerto Rico needs certainty and stability," she said in the statement released via Twitter.

Observers said the latest development plunged the island into political and economic purgatory. Some pundits even suggested that Vázquez will take the oath only to name a new secretary of state who would then take over as governor.

"It's almost a joke," said longtime political expert Mario Negron Portillio.

"In a matter of a couple of weeks Puerto Rico has had three governors. Nobody knows what time it is. Honest to God. The economy is standing still because nobody knows what's going to happen. Who wants to invest ... in Puerto Rico if you don't even know who's going to be governor next week? This is a crazy house right now."

The affair highlights the fierce infighting within Rosselló's pro-statehood New Progressive Party and threatens to deepen the political turmoil on the island, where protesters have voiced opposition to both Vázquez and Pierluisi.

Pierluisi, 60, is a corporate lawyer for the O'Neill & Borges law firm in San Juan. His firm represents the Financial Oversight and Management Board for Puerto Rico -- which Congress created in 2016 to help manage territory's financial crisis. His brother-in-law is the head of the board, known as la Junta on the island and a target of protesters who helped topple the unpopular Rosselló.

One of the more popular chants among protesters prior to Rosselló's resignation was "Ricky renuncia y llévate a la Junta" (Ricky resign and take the Junta with you.)

Pedro Pierluisi

Pierluisi is also the former resident commissioner, the island's sole non-voting representative in Congress, from 2009-2017. He also served as Puerto Rico's secretary of justice under former Gov. Pedro Rosselló, the current governor's father.

She became secretary of justice in January 2017, and is an ally of Rosselló.

Critics cite Vázquez's close ties to the outgoing governor as well as her own controversies and limited political experience. They accuse her of failing to open investigations against members of her own party, particularly Rosselló and his administration's handling of the aftermath of Hurricane Maria in 2017.

Last year, Vazquez came under fire for allegedly intervening on behalf of her daughter in a case stemming from a home theft. She faced charges of violating government ethics laws. But a judge later ruled there was insufficient evidence to arrest her.

Controversial text messages started the uproar

Rosselló stepped down on Friday following weeks of massive anti-government protests.

Protests were sparked by the release of private chat messages that exposed Rosselló and 11 top aides and Cabinet members exchanging profanity-laced, homophobic and misogynistic messages about fellow politicians, members of the media, celebrities and others.

The texting scandal followed years of alleged corruption, a debt crisis and widespread devastation by Hurricane Maria. The leaks and the unrest that followed rocked the island's administration and led to resignations of several high-profile political figures.