Burundi President Pierre Nkurunziza's attempt to return home to tackle a coup has failed and he has returned to Tanzania where he was attending a summit, officials there told the BBC.
The coup was announced by Maj Gen Godefroid Niyombare on Wednesday.
But its outcome remains unclear and the presidency insisted it had failed.
Heavy gunfire was heard early on Thursday morning near the radio and TV station in the capital, Bujumbura, Reuters news agency reports.
What's behind the coup bid?
The loyalists still reportedly hold the presidential palace and main radio offices.
"The attempted coup by General Godefroid Niyombare has been stopped," said armed forces chief General Prime Niyongabo said in a radio broadcast.
Earlier Gen Niyombare had ordered the closure of the airport to prevent Nkurunziza's plane from landing.
The UN and US urged all sides to show restraint.
In his earlier announcement of the coup, Gen Niyombare said he did not recognise the leadership because the president's bid for a third term violated the constitution.
Gen Niyombare said in a radio broadcast: "The masses vigorously and tenaciously reject President Nkurunziza's third-term mandate. President Pierre Nkurunziza has been relieved of his duties. The government is overthrown."
Analysis: BBC Africa's Venuste Nshimiyimana
The peace accord that brought an end to Burundi's brutal 12-year ethnic civil war ensured that the future army would be split 50-50 between minority Tutsis and majority Hutus. This means that unlike the police, whose officers have been forceful in putting down the anti-third term protests, the army is regarded as a neutral force.
Nevertheless within the military there are internal divisions - with former Hutu rebels regarded as loyal to the ruling party and those in the old Tutsi-dominated army seen as loyal to the opposition.
The surprise about this coup declaration is that it comes from Gen Niyombare, once a close ally of the president. However, it is unclear whether the general, fired as intelligence chief in February, can command the loyalty of all soldiers.
A few hours later the Burundi presidency dismissed the coup attempt, saying: "It is with regret that we have learned that a group from the armed forces mutinied this morning and declared an imaginary coup.
"This coup attempt has been foiled and that these people, who read the coup announcement on the radio, are being hunted by defence and security forces so that they can be brought to justice."
Nkurunziza had been in Dar es Salaam to discuss the crisis with regional leaders.
Tanzanian President Jakaya Kikwete said the summit had condemned the coup, adding: "The region will not accept, nor will the region stand by, if violence does not stop or escalates in Burundi."
Weeks of protests
The BBC's Maud Jullien in Bujumbura says thousands of protesters had marched to the centre of Bujumbura alongside soldiers and two tanks after the coup was announced on Wednesday.
One protester told the BBC this was a victory after weeks of protests.
The unrest began on 26 April and has led to the deaths of more than 20 people.
Tens of thousands of Burundians have fled to neighbouring states in recent weeks.
President Nkurunziza has rejected calls to postpone next month's election. However, the summit in Tanzania urged him to do so.
The 51-year-old former rebel leader argues that he is entitled to run for a third term because he was first appointed to the role by parliament in 2005.
The constitution states a president should govern only for two terms, but earlier this month a court upheld Nkurunziza's interpretation.
Coup bid leader: Gen Godefroid Niyombare, 46
Former rebel CNDD-FDD commander and ally of President Nkurunziza
First ethnic Hutu army chief - a significant step in reconciliation efforts
A negotiator in peace talks with last rebel group FNL
Oversaw Burundi's deployment to Somalia as part of African force
Served as ambassador to Kenya
Dismissed as intelligence chief in February three months after his appointment
Dismissal came days after he recommended against the third-term bid