Media playback is unsupported on your device Media caption Puerto Ricans celebrate Governor Ricardo Rosselló's political demise

A new governor has been sworn into office in Puerto Rico, bringing fresh controversy to the US territory.

Pedro Pierluisi is the handpicked successor of Ricardo Rosselló, who resigned amid mass protests over a leaked chat in which he and top aides shared obscenity-laced messages.

But Mr Pierluisi's term as governor could be short-lived as it is yet to be ratified by the island's Senate.

Critics argue that his appointment is unconstitutional.

In his inaugural speech on Friday, Mr Pierluisi said he was "fully capable and authorised to act, but the Senate will have its say".

"If I am not ratified then the second in line, the secretary of justice of Puerto Rico, will take over the governorship," he added.

Mr Pierluisi said he did not plan to move into the governor's mansion and would avoid any major changes until after the vote next week.

He was sworn in by a judge at 17:00 local time (21:00 GMT) on Friday - the hour that Mr Rosselló was set to leave office.

Many criticised the move, with Senate President Thomas Rivera Schatz describing it as "unethical and illegal", according to Reuters news agency.

San Juan Mayor Carmen Yulín Cruz said the municipality would be challenging his swearing-in, while one lawyers' organisation reportedly accused him of "hijacking" the constitution.

The appointment on Friday came as crowds celebrated the fall of Mr Rosselló.

Why did Rosselló step down?

Mass street rallies in Puerto Rico began after text messages between Mr Rosselló and his team were leaked on 13 July.

Obtained by Puerto Rico's Centre for Investigative Journalism, the text messages span some 900 pages. They were from a group chat that included the governor and 11 of his aides and cabinet members.

The messages include jokes about Hurricane Maria victims along with sexist and homophobic comments.

Media playback is unsupported on your device Media caption Celebrations in San Juan as Puerto Rico Governor Rosselló resigns

Mr Rosselló initially apologised but said he would not step down over the scandal. On 24 July, he announced his resignation in a recorded video statement.

"I feel that to continue in this position would make it difficult for the success that I have achieved to endure," he said.