Troops in Honduras have detained the president ahead of a referendum on plans to change the constitution.

President Manuel Zelaya was flown to Costa Rica from an air force base outside the capital, Tegucigalpa. Mr Zelaya, elected for a non-renewable four-year term in January 2006, wanted a vote to extend his time in office. The referendum, due on Sunday, had been ruled illegal by the Supreme Court and was also opposed by Congress and members of Mr Zelaya's own party. Reuters news agency reports that police fired teargas at about 500 supporters of Mr Zelaya who had gathered outside the presidential palace.

Protesters reportedly hurled rocks at the soldiers, shouting "Traitors", AP news agency reports, as tanks rolled through the streets and air force jets flew over the capital.

Early on Sunday, an AP reporter said he had seen dozens of troops surround Mr Zelaya's residence.

In other developments:
• At an emergency meeting in Washington, the Organization of American States condemned what it called a "coup" in Honduras; the EU called on the Honduran army to free the president
• Mr Zelaya's ally, Venezuelan President Hugo Chavez, blamed "the Yankee empire" for what had happened

The military's dramatic move came after President Zelaya defied a court order that he should re-instate the chief of the army, Gen Romeo Vasquez. The president sacked Gen Vasquez late on Wednesday for refusing to help him organise the referendum.
Mr Zelaya, who under current regulations leaves office next January, also accepted the resignation of the defence minister.

'US opposed coup'
The referendum was to ask the population if they approved of a formal vote next November on whether to rewrite the Honduran constitution. On Thursday, the Honduran Congress approved plans to investigate whether the president should be declared unfit to rule.
In an interview with Spain's El Pais newspaper published on Sunday, Mr Zelaya said a planned coup against him had been thwarted after the US refused to back it. "Everything was in place for the coup and if the US embassy had approved it, it would have happened. But they did not," Mr Zeleya said. The arrest of Mr Zelaya took place an hour before polls were due to open. Ballot boxes and other voting materials had been distributed by Mr Zelaya's supporters and government employees throughout the Central American country.

The president has vowed to transform Honduras, saying the system currently favours the wealthy elite. But his opponents accused him of seeking to rule indefinitely. Honduras - an impoverished coffee and banana-exporting nation of more than 7 million people - has a history of military coups. Soldiers overthrew elected presidents in 1963 and again in 1975; the military did not turn the government over to civilians until 1981.