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.
With a mix of guile and charm, Mr. Compaoré managed to juggle alliances with Western governments and the Libyan leader Col. Muammar el-Qaddafi, turning himself into a regional power broker whose influence far outweighed the resources of his nation: a poor, landlocked country where more than half of the population has had no other leader.
“The demonstrations he could live with; he’s had that over the years,” said Pierre Englebert, a professor of African politics at Pomona College in Claremont, Calif. “When they went for Parliament and set it on fire, then it went to a different level. It showed a certain resolve by the demonstrators.”
Mr. Compaoré’s dual and often contradictory roles on the continent meant that he both fed conflict and, in later years, earned praise on the international stage for working to foster peace and greater stability.
“He has always been an extremely adept and sophisticated player in that region,” said Lansana Gberie, a historian from Sierra Leone who has written about the civil war there. “It has confounded many people.”
Historians have described Mr. Compaoré as a principal supporter of Charles G. Taylor, the former Liberian president convicted in 2012 of war crimes and crimes against humanity.
During the civil war in Sierra Leone more than a decade ago, American officials accused Mr. Compaoré of fueling the violence by funneling arms to rebels and sending mercenaries to fight alongside them against United Nations peacekeepers in exchange for diamonds.
But Mr. Compaoré often took on the role of regional peacemaker as well. This year, the United Nations secretary general, Ban Ki-moon, commended him for “his contribution to peace and stability in Mali,” including his help in reaching an agreement for a cease-fire after that country, a neighbor, was split in half by an insurgency.
A few years earlier, the United Nations Security Council singled him out for “his critical role” in supporting the peace process in Ivory Coast — another country where he has been accused of stoking instability.
He remained close to the French during his presidency and came to be seen as a pro-Western leader and ally in the battle against Islamist militancy in the region.
“Over the years, Compaoré has played both the role of accomplice and peacemaker,” said Corinne Dufka, an associate director at Human Rights Watch.
As “big men” like Colonel Qaddafi, Mr. Taylor and Foday Sankoh of Sierra Leone were toppled or indicted, “he took on the role of elder statesman, filling a vacuum for the role of Francophone negotiator,” Ms. Dufka said. “But still, why Compaoré’s actions in support of abusive regimes didn’t receive more scrutiny — indeed, condemnation — has always been a bit of a mystery.”
Mr. Compaoré was only 36 when he seized power in a coup in 1987 that felled his former friend and military colleague Thomas Sankara, a national hero whose death many in Burkina Faso continue to grieve. Though the precise circumstances of the killing have long been opaque, it has cast a long shadow over Mr. Compaoré for decades, with many residents continuing to see it as an unforgivable betrayal.
The recent protests against Mr. Compaoré sprang from a legislative proposal to remove term limits from the Constitution, which would have allowed him to extend his rule.
The limits were introduced in 2000, but because of a legal technicality, they were not applied to Mr. Compaoré until the 2005 elections, which he won. In 2010, he triumphed again, but he would have been ineligible to run in 2015 unless the term limits were rescinded.
Opposition to his plans for another term had been building for weeks. Anger exploded Thursday as protesters stormed the Parliament building, bursting past police lines to prevent lawmakers from voting on a draft of the legislation.
Thousands rampaged through the capital, Ouagadougou, burning the homes of presidential aides and relatives and storming state broadcasting facilities. Social media sites showed images of demonstrators toppling a statue of Mr. Compaoré.
Residents reported that a heavily armed convoy carrying the president had been seen leaving Ouagadougou and heading south toward the border with Ghana, even as his resignation announcement was read aloud television. There were reports, too, that residents had barricaded roads to prevent him from fleeing.
Gen. Honoré Nabéré Traoré, the chief of staff of Burkina Faso’s armed forces, said at a news conference that he would “assume the responsibilities of head of state.” He said he was acting to fill the power vacuum left by Mr. Compaoré’s departure and to “save the life of the nation.”
Only hours earlier, General Traoré had announced plans to form a transitional government leading to elections in a year’s time.
It is not immediately clear how popular the general’s action will be, since he is regarded as close to Mr. Compaoré. Many protesters had said they favored the former defense minister, a retired general, Kouamé Lougué, to oversee a transition to new elections.
Later in the day, the military officer who had announced that Mr. Compaoré was no longer in office, Lt. Col. Isaac Zida, seemingly also staked a claim to power, saying he was the new president, Reuters reported.
Mr. Compaoré had declared martial law for a few hours on Thursday, but then seemed to relent, offering negotiations on a transitional government and rescinding his martial-law decree.
Overnight, the president said he had “heard the message” from the protesters and understood “the strong desire for change.”
As huge crowds gathered in Ouagadougou, one army officer signaled that the military had abandoned the president, telling protesters that the army was “henceforth at the side of the people.”
Tom McDonald, a lawyer and former United States ambassador to Zimbabwe, said he doubted that the uprising in Burkina Faso would lead to the ouster of longtime rulers in other African nations.
“I would say it’s happy talk to predict a Sub-Saharan Africa Spring,” Mr. McDonald said. At the same time, he added, such events do not go unnoticed among other leaders.
“These guys look around at each other,” he said. “When the music stops, how many chairs are left?”