By Ricardo Brito and Anthony Boadle
RIO DE JANEIRO/BRASILIA (Reuters) - Jair Bolsonaro, a far-right firebrand former Army captain, won Brazil's presidential election in convincing fashion, wooing voters with promises to gut endemic political corruption and wage a brutal battle against powerful drug gangs.
Bolsonaro, who early in his legislative career declared he was "in favour" of dictatorships and demanded that Congress be disbanded, vowed after his Sunday night win to adhere to democratic principles while holding up a copy of the country's Constitution.
U.S. President Donald Trump said he had an "excellent call" congratulating Bolsonaro and tweeted about their plans to "work closely together on Trade, Military and everything else!"
Markets also cheered Bolsonaro's victory, sending Brazil's benchmark Bovespa stock index to an all-time high on his pledges to balance the federal budget and privatise state firms.
Bolsonaro's transition team planned to meet on Monday with President Michel Temer's team to start work ahead of his Jan. 1 inauguration.
Bolsonaro's win alarmed critics around the globe, mainly because of his vows to sweep away leftist political opponents and his history of making insulting comments about gays, women and minorities.
His victory brings Brazil's military back into the political limelight after it spent three decades in the barracks following the country's 1964-1985 dictatorship. Several retired generals will serve as ministers and close advisers.
"You are all my witnesses that this government will defend the constitution, of liberty and of God," Bolsonaro said in a Facebook live video in his first comments after his victory.
An outspoken Trump admirer, Bolsonaro also vowed to realign Brazil with more advanced economies such as the United States, overhauling diplomatic priorities after nearly a decade and a half of leftist rule.
Bolsonaro joins a list of populist, right-wing figures to win elections in recent years such as Trump, Philippine President Rodrigo Duterte and Hungarian Prime Minister Viktor Orban.
Trump's friendly congratulatory call augurs closer political ties between the two largest economies in the Americas - both now led by conservative populists promising to overturn the political establishment.
Bolsonaro won 55.2 percent of votes in a run-off election against left-wing hopeful Fernando Haddad of the Workers Party (PT), who garnered 44.8 percent, according to electoral authority TSE.
The 63-year-old congressman's rise has been propelled by rejection of the leftist PT that ran Brazil for 13 of the last 15 years and was ousted two years ago in the midst of a deep recession and political graft scandal.
Thousands of Bolsonaro supporters cheered and set off fireworks outside his home in Rio de Janeiro's beachfront Barra de Tijuca neighbourhood as his victory was announced.
Investors also cheered Bolsonaro's ascent, relieved that he could keep the PT out of power and hopeful that he would carry out fiscal reforms proposed by his orthodox economic guru.
"I don't idolize Bolsonaro and I don't know if he will govern well, but we are hopeful. People want the PT out, they can't take any more corruption," said Tatiana Cunha, a 39-year-old systems analyst in the midst of the noisy celebrations.
Bolsonaro has promised to cut bureaucracy for businesses. He said he was committed to fiscal discipline and called for the early elimination of the federal government's budget deficit.
Brazil's benchmark Bovespa stock index rose 2.4 percent, led higher by shares of state-owned firms and blue-chips. Preferred shares in state oil company Petróleo Brasileiro SA advanced 3.6 percent, while lender Itaú Unibanco Holding SA jumped 3.3 percent.
The real currency has gained about 10 percent against the dollar in the last 30 days as Bolsonaro's prospects of winning increased. Sao Paulo's benchmark Bovespa stock index has risen 13.5 percent since mid September.
Investors are particularly heartened by his choice of Paulo Guedes, a Chicago University-trained economist and investment banker, as his economic guru and future economy minister.
Guedes, who wants to privatise an array of state enterprises, said the new government will try to erase Brazil's unsustainable budget within a year, simplify and reduce taxes, and create 10 million jobs by cutting payroll taxes. New rules will boost investment in infrastructure, he told reporters.
(Reporting by Ricardo Brito in Rio de Janeiro and Anthony Boadle in Brasilia; Additional reporting by Gabriel Stargardter and Rodrigo Viga Gaier in Rio de Janeiro, Brad Brooks in Sao Paulo and Jake Spring in Brasilia; Editing by Neil Fullick and Alistair Bell)