The 50-year-old rum manufacturer, known as a fervent Roman Catholic and member of the conservative church group Opus Dei, had a falling-out with Martinelli after the president dismissed Varela from his foreign minister post in 2011.

The move opened a political wound that has yet to heal. But now Varela can savor his political revenge from the presidential mansion.

Martinelli, a supermarket magnate, had been an outspoken supporter of Arias, a former housing minister and a businessman who made his fortune manufacturing ladies' undergarments.

Juan Carlos Navarro, the 52-year-old former mayor of Panama City who represented the center-left Democratic Revolutionary party, acknowledged defeat.

The race was expected to be among Panama's tightest. Yet Varela had been running third and scored at least a touch of an upset.

In addition to picking a new president, the country's 2.5 million eligible voters were electing dozens of mayors and members of Congress.

Staying the course Lawyer and political analyst Ebrahim Asvat said that whatever the outcome of the vote, the country's course for the next quarter century already has already been mapped out.

Panama will continue to focus, he said, on free market policies that maximize economic expansion -- the path forged by Martinelli, who is leaving office with a 67 percent approval rating.

"Panama has made an extraordinary effort to open up its economy, exercise fiscal discipline and none of the candidates is going to veer from that path," Asvat said.

The country enjoyed blistering growth of 8.5 percent last year, but economic inequality remains a major concern, with about 26 percent of citizens living in poverty.

Panama long has traded on its canal, shipping and trade, but increasingly is turning to unconventional exports such as mining, plus tourism and other service industries, such as catering to expat retirees.

Uneven patterns of economic distribution have only been reinforced during the current boom, and that is unlikely to change.

"Economic growth has benefited a small elite," said Jaime Purcell, a political analyst focusing on Panama's electoral process.

"Regardless of who wins, there is not going to be major (policy) change."

Not everyone is thrilled with the status quo, however.

"Whoever wins, I still have to go to work on Monday," shrugged Manuel Dominguez, a sidewalk merchant who makes his living selling batteries and TV remotes in the heart of Panama City.

Dominguez grumbled about rising prices, even though inflation in Panama is a relatively modest four percent.

"Everything is super-expensive," he said, adding that his vote was for Varela, who has vowed to curb inflation by imposing price controls, a policy more commonly associated with the left.