Major General Godefroid Niyombare made his bid for control just hours after President Pierre Nkunrunziza flew to neighbouring Tanzania for talks with regional leaders.
He has accused the president of violating the constitution by seeking a third term.
Thousands of people turned out to celebrate the attempted coup.
President Nkurunziza used Twitter to called it a “failed” coup and later announced he was returning to the country – but General Niyombare has other ideas.
“I order the closure of the airport and border, and I ask every citizen and law enforcement down to the airport to protect it,” he said in a radio broadcast.
Sporadic gunfire was heard on the streets of Bujumbura after the attempted coup was announced.
General Niyombare – a powerful former intelligence chief who was sacked earlier this year – told a national radio station: “Given the necessity to preserve the country’s integrity… the President Pierre Nkunrunziza is dismissed from his functions.”
It follows weeks of protests against Nkurunziza’s decision to stand for a third term.
Fifteen people have died during unrest.
Protesters have been trying to prevent him from standing for re-election, because they see him as a repressive, divisive leader incapable of reducing the country’s extreme poverty.
Relative normality has now resumed in the the capital, prompting President Nkurunziza’s office to write on social media: “A group of soldiers mutinied this morning and made a fantasy declaration of a coup d’etat.
“This attempted coup was foiled and these people… are sought by defence and security forces so they are brought to justice.”