The court said Mr Cortizo of the Democratic Revolutionary Party won 33%, with 95% of votes counted from Sunday’s vote.

It said Mr Cortizo, a cattle rancher, will formally be named president-elect on Thursday.

He said on Monday morning: “I call on all Panamanians to join in a national effort to correct the country’s path, rescue the country and get the economy on the right track.”

Laurentino Cortizo waves to supporters in Panama City (Arnulfo Franco/AP)

Second-placed candidate and businessman Romulo Roux, of former president Ricardo Martinelli’s Democratic Change party, won 31% of the vote but has not conceded defeat.

The campaign focused on corruption and slowing economic growth in this Central America trade and financial hub and turned into the tightest presidential contest in recent years.

Before the announcement, Mr Roux vowed not to concede defeat, saying the results were too close and suggesting the race was marred by irregularities.

“We have to guarantee the protection of the electoral process and of democracy. Right now, it’s in doubt,” he said, without providing any evidence of election tampering.

Romulo Roux arrives to vote in Panama City with his wife and daughter (Arnulfo France/AP)

The PRD, which has social-democratic leanings, will return to power for the third time since the transition to democracy three decades ago following the end of a military-led regime. The last time it in power was from 2004 to 2009 during the administration of Martin Torrijos.

There is no run-off in Panama, so the winner in the field of seven mostly business-friendly candidates wins outright and takes office on July 1 for a five-year term.

The election followed revelations of money laundering in the so-called Panama Papers that damaged the country’s reputation on the world stage. The trove of secret financial documents showed how some of the world’s richest people hid their money using shell companies in Panama and other countries.

}
});

#bb-iawr-inarticle- { clear: both; margin: 0 0 15px; }

Despite the scandal, Panama remains a strategic location for commerce, anchored by the heavily trafficked Panama Canal shipping route and a recently expanded international airport.

An electoral worker shows a ballot during a manual count (Arnulfo Franco/AP)

Mr Cortizo, a 66-year-old who studied business administration in the US, was agriculture minister under Mr Torrijos and campaigned on vows to clean up Panama’s image after the corruption scandals.

Mr Roux, a 54-year-old businessman, had the endorsement of supermarket magnate Mr Martinelli, who is in jail awaiting trial on charges of political espionage. Mr Roux held multiple government posts during the Martinelli administration, including minister of canal affairs and foreign minister.

Turnout was strong at 72% for Panama’s sixth presidential election since a US invasion ousted strongman Manuel Noriega in 1989.

Outgoing president Juan Carlos Varela, a 55-year-old conservative and liquor industry veteran, was barred by the constitution from running.