(Adds Colombia apology, document accusation, background, adds double byline and changes to double dateline)
CARACAS/QUITO, March 2 (Reuters) - Venezuela and Ecuador sent troops to their borders with Colombia on Sunday after their Andean neighbor bombed Colombian rebels inside Ecuador in an attack Caracas said could spark a war.
Venezuelan President Hugo Chavez also deployed tanks to the frontier, mobilized warplanes and withdrew his diplomats from Bogota in the worst dispute in the unstable region for years.
Ecuadorean President Rafael Correa, a close ally of the leftist, anti-U.S. Chavez, expelled Colombia's ambassador and recalled his own envoy from Bogota in protest over what he said was an intentional violation of his nation's sovereignty.
Colombia responded to Correa by offering its apologies for the troops crossing the frontier, but said the operation on a jungle rebel camp was necessary because its forces came under fire from inside Ecuador.
But Colombia, a U.S. ally, also said it found documents at the camp that linked Correa to the the guerrillas.
"May God spare us a war. But we are not going to allow them to violate our sovereign territory," Chavez, an ex-paratrooper said.
Colombia's troops killed on Saturday Raul Reyes, a leader of Marxist FARC rebels, during an attack on a jungle camp in Ecuador in a severe blow to Latin America's oldest guerrilla insurgency. The operation included air strikes and fighting across the border.
Chavez, who had warned a similar operation in Venezuela would be "cause for war," threatened to send Russian-made fighter jets into U.S. ally Colombia if its troops also struck inside his OPEC country.
He and Correa both accused Colombian President Alvaro Uribe of lying over the attack.
Colombia said it had no intention of violating Ecuador's sovereignty, saying it acted in "legitimate defense."
TROOPS ON ALERT
But Correa said Colombian warplanes entered Ecuador's air space to bomb guerrillas while they were sleeping and then flew troops into the camp in helicopters.
"This was a massacre," said Correa. "We even found bodies shot in the back ... We will not allow this to go unpunished."
Venezuela's armed forces went on alert and will support Ecuador, its poorer, smaller ally, "to the last," Chavez said.
Washington, which backs Uribe's fight against the rebels with its largest military aid outside the Middle East, said it was monitoring developments after Chavez's "odd reaction."
France called for restraint on all sides, saying the situation underlined the need for the negotiated release of FARC hostages, including the most high-profile captive, French-Colombian politician Ingrid Betancourt.
The FARC said in a statement the killing of a leader who had been involved in hostage talks should not affect moves to free captives, according to the Venezuelan government.
Uribe, who is popular at home for his tough stance against the rebels, has often jousted with neighbors over spillover from the four-decade conflict. But he has managed differences with pragmatism and disputes have rarely moved past rhetoric.
Political analysts said a conflict was unlikely because Chavez -- the leader of Andean leftists -- was more interested in firing up his support base with rhetoric against Colombia. He can ill afford to lose the neighbor's food imports amid chronic shortages, they added.
"We believe a military conflict between the two nations is unlikely at this stage but the growing political tension sets the stage for a potential overreaction to future events increasing the risk of costly miscalculations and missteps," Goldman Sachs economist Alberto Ramos said.
Chavez has been in a diplomatic dispute with Uribe for months over his mediation to free the rebels' hostages. Uribe says Chavez used the talks to meddle in Colombian affairs.
The Venezuelan called the rebel leader's death the "cowardly assassination" of a "good revolutionary."
Additional reporting by Caracas, Quito, Bogota bureaux, Jean-Baptiste Vey in Paris and David Alexander in Crawford; Editing by Sandra Maler
Our Standards: The Thomson Reuters Trust Principles.