(Adds court vote to exclude Odebrecht testimony)
BRASILIA, June 8 (Reuters) - Brazil's top electoral court on Thursday excluded testimony of engineering company executives from an illegal campaign funding trial against President Michel Temer, a move that suggested it would throw out a case that had threatened to unseat him.
The Supreme Electoral Tribunal voted 4-3 to exclude plea-bargain testimony of Odebrecht SA executives after chief judge Gilmar Mendes said any ruling had to consider the stability of the country and Temer should not be compelled to step down for a minor reason.
In Brazil's largest ever graft scandal, the executives told prosecutors they funneled millions of dollars into the 2014 re-election campaign of former president Dilma Rousseff and her then running mate Temer.
Exclusion of the plea bargain testimony strengthens Temer's case that his campaign received no illegal funds.
A guilty ruling against Temer would annul the 2014 election result and unseat him, though he could appeal and remain in office until a final decision that could take months. That would deepen uncertainty over the fate of his economic reform agenda aimed at plugging a gaping budget deficit and pulling Brazil out of its worst ever recession.
The court, which began hearing the case on Tuesday, is expected to rule later on Thursday or on Friday. Mendes, as well as justices Napoleão Nunes Maia, Admar Gonzaga and Tarcísio Vieira, argued against allowing the Odebrecht testimony.
The Temer and Rousseff defense teams requested the testimony be scrapped by the court, holding that it went beyond the scope of an original complaint filed by the Brazilian Social Democracy Party after it lost the 2014 election.
"Temer has the votes to stay in office," said Welber Barral, a Brasilia insider and political consultant who is following the case closely, as is much of the country and its investors.
Barral said the court, known as the TSE, would most probably vote 4-3 to throw out the case to annul the Rousseff-Temer ticket. Any of the seven judges, however, could ask for time to study the case, which could delay a final ruling for weeks.
Brazil's currency strengthened as investors sensed the court would likely favor Temer, raising the survival chances of his measures to close the budget deficit. Interest rate futures, a gauge of concern over Brazil's future, fell off morning highs on the decision to exclude Odebrecht testimony.
IF TEMER SURVIVES TSE, UNLIKELY TO FALL
Temer opponents had been counting on a TSE ruling against the scandal-hit president to force him from office. The country is caught in a political crisis triggered by its biggest ever political graft investigation and last year's impeachment of Rousseff, whose supporters called it a soft coup arranged by Temer and allies to thwart the graft probe.
Temer himself is under investigation for allegedly receiving millions in bribes and obstruction of justice, and Brazil's top federal prosecutor is widely expected to formally charge him soon.
Temer has canceled meetings to follow the court session on television in his presidential office, an aide said. "The president is confident his defense with prevail," spokesman Marcio de Freitas told Reuters.
If Temer is forced from office, lower house Speaker Rodrigo Maia would take over, and Congress would have 30 days to pick a caretaker to lead the country until elections in late 2018.
Temer has refused to resign despite bribery allegations made in plea-bargain testimony by executives of the world's largest meatpacker JBS SA.
If Temer survives the electoral court case and is charged by prosecutors for corruption, he is unlikely to fall.
For the top court to put him on trial, the charges would have to be authorized by two thirds of the lower chamber of Congress, where his allies are still a majority.
The PSDB party, Temer's main coalition ally, delayed until Monday a meeting on whether to pull its three ministers from his cabinet, which would erode his support in Congress, but not to the point that charges against him would pass the chamber.
(Reporting by Ricardo Brito and Anthony Boadle; Additional reporting by Bruno Federowski in São Paulo Editing by W Simon and Andrew Hay)