Leftist Mauricio Funes of El Salvador's former Marxist rebel FMLN party has won the country's presidential election.
He defeated his conservative rival, the Arena party's Rodrigo Avila, who has admitted defeat.
Arena had won every presidential election since the end of El Salvador's civil war 18 years ago.
Addressing jubilant supporters, Mr Funes said it was the happiest day of his life and the beginning of a new chapter of peace for the country.
Branded by his opponents as a puppet of Venezuala's President Hugo Chavez, Mr Funes vowed to respect all Salvadorian democratic institutions.
The FMLN won 51.3% of the vote against Arena's 48.7%, Reuters news agency reported.
Break with tradition
"This is the happiest night of my life, and I want it to be the night of El Salvador's greatest hope," said Mr Funes.
Mauricio Funes is the first FMLN leader who has not been a combatant
"I want to thank all the people who voted for me and chose that path of hope and change."
His FMLN (Farabundo Marti National Liberation Front) party was founded by Marxist guerrilla fighters from the civil war.
The conflict ended in a UN-sponsored peace accord in 1991, after the loss of some 70,000 lives over less than two decades.
Mr Funes, a former television journalist, marks a break of tradition for the party as he is the first of its leaders not to have been a combatant in that war, says the BBC's Stephen Gibbs in El Salvador.
He stressed his moderate policies during his campaign and says he intends to maintain good relations with the United States.
He strongly rejected suggestions put forward by his political opponents that El Salvador under his watch would become a Venezuelan satellite state.
Supporters of Mr Avila, a former police chief, dismissed the FMLN as "communists".
Mr Funes will take over a country plagued with problems, our correspondent notes.
El Salvador has one of the world's highest murder rates.
It has also been badly hit by the world economic downturn, with remittances from Salvadorians living abroad falling dramatically.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.