UPDATE 2-Puerto Rico Supreme Court rules new governor must step down

(Recasts first sentence with potential successor, adds statement from justice secretary)

SAN JUAN, Aug 7 (Reuters) - The Puerto Rico Supreme Court on Wednesday ruled that last week's swearing in of Pedro Pierluisi as governor was unconstitutional and that he must leave office later in the day, paving the way for Justice Secretary Wanda Vazquez to succeed him.

In a unanimous decision, the nine-member high court nullified his 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.

Pierluisi has said he would abide by the supreme court's decision, which set a 5 p.m. local time deadline for him to leave office. Vazquez said she will assume the governorship under the succession plan in Puerto Rico's constitution.

"Puerto Rico needs certainty and stability," she said in a statement.

The high court's ruling followed weeks of political turmoil in the bankrupt U.S. territory, where Governor Ricardo Rossello, left office last Friday in the wake of days of protests demanding he resign.

Pierluisi, Rossello's hand-picked successor, was appointed secretary of state and next in line for governor on July 31. He was sworn in as governor last Friday.

His swearing in as governor came after only the Puerto Rico House of Representatives, in a special session, confirmed him as secretary of state. 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 July 31 appointment by Rossello 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 take over as governor despite his lack of confirmation by both legislative chambers. (Reporting by Luis Valentin Ortiz in San Juan Additional reporting by Karen Pierog in Chicago Editing by Matthew Lewis)