The Governor of Puerto Rico, Ricardo Rosselló, has announced his resignation after days of mass protests in the US territory.
Mr Rosselló, who only insisted on Sunday that he would stay, said he would continue to work until 2 August, to allow this an orderly transition.
He was involved in a group scandal that already led two senior officials to resign.
The leaked news revealed sexist, profane and homophobic comments.
The chat, which included 880 pages of exchanges between the governor and 11 male allies, leaked on July 13 and led to protest days outside the Governor's Mansion in San Juan.
What did Governor Rosselló say?  He recorded a video that aired on Wednesday night.
"I announce that I will resign from my position as governor with effect from Friday, August 2, at 5:00 PM," Rosselló said, reaching to endure, "he added.
The announcement Mr Rosselló set off on the streets of the capital San Juan.
Hundreds of thousands took to the streets on Monday calling for the immediate resignation of Mr Rosselló.
The 40-year-old Governor is chairman of the New Progressive Party, a Puerto Rican newspaper Party advocating US statehood
Rosselló is being replaced by USAW justice minister Wanda Vazquez.
When he tried to appease the demonstrators on Sunday, he said he would not request re-election next year.
"I hear you," Rosselló said in a Facebook video. "I made mistakes and apologized."
"I know that apology is not enough," he added.
What are the secret messages?
Several of the texts ridicule the victims of hurricane Maria, who devastated the island in 2017 and possibly caused more than 4,000 deaths.
In one case, Rosselló criticized former New York City Council spokeswoman Melissa Mark-Viverito, saying people should "beat up this whore".
When the island's tax office wrote that he wanted to "shoot" the mayor of San Juan, Mr. Rosselló replied: "They would do me a great favor."
How did the scandal react?
The local newspaper El Nuevo Día called on the governor to resign from Monday's editorial.
] "Puerto Rico has not only spoken as a strong, broad and united voice, but as the right voice," said the editorial. "With a gesture of nobility and humility, Governor, it's time to listen to people, they must resign."
Carmen Yulin Cruz, mayor of San Juan, said Monday in a Twitter message: "You can not deny it: the power is on the road."
Singer Ricky Martin, the target in the secret messages Served, among other things, called for the resignation of the governor and the Hamilton creator Lin-Manuel Miranda and the reggaeton stars Bad Bunny.  Bad Bunny Stops Tour in Puerto Rican Protest
"They mocked our dead, ridiculed women, mocked the LGBT community, made fun of people with physical and mental disabilities, made fun of obesity It's enough, it can not be, "said Martin in a video on Twitter.
The island's political crisis also made headlines across mainland America. Many felt that the Editorial Board of the New York Times was fine, writing that the "callous and partisan selfishness" found in the messages was an exorbitant burden on the suffering island, effectively "sifting salt into a long-smoldering wound."
"The Puerto Rican people have no use for minor political feuds," the New York Times wrote. "Their territory is under pressure from corruption, incompetence and indifference of the government, they have failed at all levels and have no more patience, they deserve it better."
US President Donald Trump has also called on the governor to resign.