Puerto Rico's Supreme Court ruled on Wednesday that the swearing-in of Pedro Pierluisi as the island's governor was unconstitutional.
His replacement, Pedro Pierluisi, was removed by the Supreme Court on constitutional grounds after five days.
The high court's ruling followed weeks of political turmoil in the bankrupt USA territory, where Governor Ricardo Rossello, left office last Friday in the wake of days of protests demanding he resign.
The ruling by the Caribbean island's top court cleared the way for Justice Minister Wanda Vazquez, who is next in the line of succession, to replace Pierluisi as acting governor.
She had publicly stated that she was not interested in becoming governor but was next in line to Mr Pierluisi, according to the constitution.
The island's justice secretary, Wanda Vazquez, was sworn in as governor at the supreme court in San Juan.
Ms Vázquez has promised to bring political stability to Puerto Rico, which was devastated by Hurricane Maria two years ago.
"When I assumed the position of governor last Friday, I did it based on the express language of Puerto Rico's Constitution and the law in force at that time", Pierluisi said in a statement, adding that he acted under laws that "are presumed constitutional, and therefore valid".
But the court on Wednesday declared as unconstitutional the part of the law that allowed Pierluisi to take over as governor despite his lack of confirmation by both legislative chambers.
Rossello, Pierluisi and Vazquez are all members of Puerto Rico's New Progressive Party (PNP), which favors annexation of Puerto Rico as the 51st USA state.
Pierluisi was sworn in as governor last Friday following confirmation of his secretary of state appointment by only the Puerto Rico House of Representatives.
Pierluisi said previously he would respect whatever ruling was made.