(Adds details from decision)
BRASILIA, Nov 23 (Reuters) - The head of Brazil's electoral court Alexandre de Moraes on Wednesday rejected a complaint from President Jair Bolsonaro's allies to challenge the presidential election, which the incumbent lost by a small margin, according to a court document.
Leftist ex-President Luiz Inacio Lula da Silva narrowly defeated Bolsonaro in the Oct. 30 runoff election, marking a stunning comeback for the leftist former president and the end of Brazil's most right-wing government in decades.
Lula's margin of victory was by less than two percentage points.
Moraes, who serves as a Supreme Court justice, also fined the parties in Bolsonaro's coalition to the tune of 22.9 million reais ($4.27 million) for what the court described as bad faith litigation, the document showed.
On Tuesday, Bolsonaro's Liberal Party (PL) filed a complaint to challenge the outcome of the election claiming some of the electronic voting machines were flawed and those votes should be invalidated, an argument that election authorities met with skepticism.
Under the terms of Wednesday's electoral court decision, political funds for the president's coalition parties were ordered blocked until the fine is paid. The ruling also ordered an investigation into any misuse of the party's structure and funds by PL head Valdemar da Costa Neto.
In the ruling, Moraes described the challenge as "offensive" to democratic norms, adding that it sought to encourage criminal and anti-democratic movements.
"The ballot boxes generate files that make it possible to identify precisely which equipment they were generated on. When one of these mechanisms stops working, others replace it, without affecting its traceability and the possibility of identifying ballot boxes," according to the decision.
Election experts and political analysts blasted the election challenge from Bolsonaro allies as weak on the merits, though it could still fire up supporters who have been protesting his defeat at the polls. ($1 = 5.3591 reais) (Reporting by Ricardo Brito; Writing by Peter Frontini; Editing by David Alire Garcia and Sandra Maler)