Outsider Juan Carlos Varela wins Panama election
Opposition leader Juan Carlos Varela has won the presidential election in Panama with almost 40% of the votes.
Mr Varela, who is currently the vice-president, had distanced himself from outgoing President Ricardo Martinelli.
Correspondents say Mr Varela has taken credit for Mr Martinelli's economic success, but has promised a cleaner, more transparent government.
The president's preferred candidate, the governing party contender Jose Domingo Arias, came second.
'May God help us'
President Martinelli had actively supported the campaign of Mr Arias, 50, and the leader's wife Marta Linares was the candidate's running mate.
Critics said his support for the Arias-Linares team was an attempt by Mr Martinelli to hold on to the reins of power.
Under the Panamanian constitution, presidents are obliged to step down after one term and are banned from running for the two following terms.
Mr Varela, a former centre-right ally of Mr Martinelli, fell out with the president after he was dismissed from his post as foreign minister in 2011.
After he had achieved an unassailable lead in the poll, Mr Varela, 50, told Reuters news agency that "better times are on their way".
Alluding to allegations of corruption against Mr Martinelli's government, he said his would be "an honest, humane government of national unity".
Hearing of Mr Varela's win, Mr Martinelli said "I know the candidate, and really, may God help us!".
He said in light of Mr Varela's success he would change his plans of "enjoying life" and go into opposition instead.
Mr Varela struck a conciliatory note, saying it was time "to put the party banners away and to govern under one flag, that of Panama".
Despite his unexpected win in the presidential poll, Mr Varela's party only got 11 of the 71 seats in Congress which were also up for election.
After his swearing-in on 1 July, Mr Varela will therefore have to form alliances with the opposition to push his planned reforms through the legislature.
He faces the challenge of maintaining buoyant growth while dealing with economic inequality, with a quarter of the population living in poverty.
Mr Varela will also have oversight of a major expansion of the Panama Canal, which accounts for 8% of gross domestic product in the country.
Recent discontent led to a nationwide construction strike over pay, which halted work on the canal and thousands of other projects.
Among the first leaders to congratulate Mr Varela was Venezuelan President Nicolas Maduro.
Venezuela earlier this year broke ties with Panama accusing the Central American nation of fomenting a coup against President Maduro by offering support to a Venezuelan opposition leader.
Mr Maduro said he hoped "to move towards an improvement of our relations".