OUAGADOUGOU, Burkina Faso — He recently boasted that the streets would never oust him, not after he had won at the ballot box and survived multiple violent outbursts against his 27-year rule.

But after days of turmoil in which protesters burned the Parliament building here and set fire to the homes of his relatives and aides, President Blaise Compaoré of Burkina Faso announced Friday that he had stepped down — a rare case of the kind of popular uprising that toppled autocrats during the Arab Spring succeeding in sub-Saharan Africa.

The political demise of Mr. Compaoré, 63, who stoked some of the region’s worst conflicts but later refashioned himself into an elder statesman committed to resolving them, closed the book on one of Africa’s most enduring rulers in a region where some leaders cling to power for decades.

“When you imagine that our young men and women who are now 27 years old have known a single president, it’s absurd,” said Issouf Traoré, a 44-year-old business owner who took to the streets this week to demand the president’s resignation.