OUAGADOUGOU, Burkina Faso — The government of Burkina Faso collapsed on Thursday as demonstrators protesting President Blaise Compaoré's plans to stay in office after 27 years surged through the streets of Ouagadougou, the capital, overrunning state broadcasters, setting fire to the Parliament building and burning the homes of the president’s relatives.

Authorities imposed martial law, according to a communiqué from the presidential palace.

After several hours of increasingly violent protests, a government spokesman announced that a bill to extend the term of Mr. Compaoré had been dropped, or at least delayed. Yet the protests continued, and later in the day, Mr. Compaoré announced that the government had been dissolved and promised more talks with the opposition “to end the crisis,” according to a statement read on a local radio station.

Still later, according to The Associated Press, he spoke briefly on television and vowed to remain in office.

If the protests do unseat Mr. Compaoré, it will be the first time since the Arab Spring that a popular movement has succeeded in removing an autocrat in sub-Saharan Africa. When the wave of Arab Spring protests first swept northern Africa, analysts predicted they would spread south, where some of the world’s most entrenched leaders continue to cling to power.