Obama administration officials said that they were surprised by the coup on Sunday. But they also said that they had been working for several weeks to try to head off a political crisis in Honduras as the confrontation between Mr. Zelaya and the military over his efforts to lift presidential term limits escalated.

The United States has long had strong ties to the Honduras military and helps train Honduran military forces. Those close ties have put the Obama administration in a difficult position, opening it up to accusations that it may have turned a blind eye to the pending coup. Administration officials strongly deny the charges, and Mr. Obama’s quick response to the Honduran president’s removal has differed sharply from the actions of the Bush administration, which in 2002 offered a rapid, tacit endorsement of a short-lived coup against Mr. Chávez.

On June 2, Obama administration officials got a firsthand look at the brewing political battle when Secretary of State Hillary Rodham Clinton traveled to Honduras for an Organization of American States conference. Mrs. Clinton met with Mr. Zelaya, and he reportedly annoyed her when he summoned her to a private room late in the night after her arrival and had her shake hands with his extended family.

During a more formal meeting afterward, they discussed Mr. Zelaya’s plans for a referendum that would have laid the groundwork for an assembly to remake the Constitution, a senior administration official said.

But American officials did not believe that Mr. Zelaya’s plans for the referendum were in line with the Constitution, and were worried that it would further inflame tensions with the military and other political factions, administration officials said.