SAN JUAN, P.R. — The people of Puerto Rico knew him first as Ricky, the handsome boy who moved into the governor’s residence when he was just 13. His father was the governor, and Ricardo A. Rosselló grew up as a child of privilege in historic La Fortaleza, a palatial 16th-century mansion with heavy drapes and thick wooden doors just steps from San Juan Bay.

Now the governor himself, Mr. Rosselló lives in the same colonial fortress of his youth, with a family of his own. But the estate had turned into a cage, guarded by police officers in riot gear and ringed by protesters who wanted him gone.

After days of escalating protests, Mr. Rosselló has announced that he is resigning from office, an unprecedented step in Puerto Rico’s history that brings a promising political career, for now, to a disgraceful end. “My only north has been the transformation of this island and the well-being of our people,” he wrote in a resignation letter made public on Thursday, the morning after a late-night, online address to the public.

It took just two weeks for his administration to reach the point of collapse, undermined by a popular uprising that the governor initially thought he could withstand. Yet Mr. Rosselló misread the anger brewing among his people after years of economic stagnation and broken promises.