A former dictator's son, Martin Torrijos, has been voted in as Panama's next president.
Martin Torrijos made full use of his father's legacy
His main rival, ex-President Guillermo Endara has conceded defeat to Mr Torrijos, who is the son of former military leader Omar Torrijos.
The BBC's Claire Marshall says Mr Torrijos has made full use of his late father's legacy.
Omar Torrijos is seen as the man who got Panama back its canal from the hands of the Americans.
"If my father were here, he would be proud of what we accomplished today," Mr Torrijos said in his victory speech.
"I invite everyone to join in a new social pact against poverty, corruption and despair,
"It will be a social pact of solidarity, social justice, opportunity and prosperity."
Mr Torrijos, a 41-year-old social democrat, had been the favourite to win Sunday's vote.
He will replace President Mireya Moscoso, who is leaving office after a five-year term - the maximum allowed under the constitution.
Test for democracy
Our correspondent says the election has shown how far the country's democracy has matured in the 15 years since Noriega's departure.
The vote was seen as being free and fair, and no election irregularities were reported. Voter turnout reached nearly 80%.
In his concession speech Mr Endara said: "I am happy because our democracy emerged from this untouched."
Mr Endara was president from 1989-94, and was seen as being responsible for Panama's economic recovery after the US invasion and ouster of dictator, Manuel Noriega.
Aged 67, he had dismissed concerns from some that he was too old to be running.
"I'm enjoying good health and I receive vital energy from the people who are accompanying me in this," he said on the campaign trail.
But in the end voters consigned him to the past, our correspondent says.
Ms Moscoso was Panama's first woman president, beating Mr Torrijos at the last election in 1999.
She is the widow of Arnulfo Arias, who had been president three times.