Economist Ricardo Lagos, one of the bravest dissidents during Augusto Pinochet's brutal 17-year military regime, defeated a strong bid by a former Pinochet ally in presidential elections today to restore the Socialists to power for the first time in 27 years.

With his arms upraised only a block from the presidential palace that still bears the scars of the 1973 military coup that ousted Salvador Allende and brought Pinochet to power, Lagos claimed victory and promised to ease restrictions on Chile's democracy.

Lagos's election coincides with Pinochet's anticipated release from 15 months of house arrest in Britain on the grounds he is medically unfit to stand trial for widespread human rights abuses. But in an indication of how much Chile has changed in the 10 years since Pinochet relinquished power, Lagos has promised to permit a fair and independent legal process that could lead to the once-unthinkable--putting Pinochet on trial in Chile.

With nearly all the ballots counted, Lagos, a 61-year-old economist trained at Duke University, received 51.32 percent of the vote, compared with 48.68 percent for Joaquin Lavin, a 46-year-old economist from the University of Chicago and a former Pinochet adviser.

Although the victory was narrow, it was almost 3 percentage points wider than Lagos's victory in the first round of voting last month, when he won by 30,000 votes. In an extraordinary move, Lavin visited Lagos and conceded defeat, then appeared on the balcony of a downtown hotel to embrace both Lagos and his wife.

Tens of thousands of supporters descended on Santiago's Constitution Plaza, tying up miles of traffic in a sea of red, white and blue Chilean flags. Among them were torture victims and relatives of the more than 3,000 people who disappeared or were murdered during Pinochet's dictatorship. They cried tears of joy as they sang, "Feel it, feel it, Lagos is president!"

"Justice has finally returned to Chile," said congresswoman Isabel Allende, daughter of Salvador Allende, who died during Pinochet's coup.

But Lagos, a moderate Socialist whose policies bear little resemblance to Allende's Marxist speeches, spoke of national unity, and of a new era of greater economic and social equality for this long-troubled country of 14 million. He will succeed Christian Democrat Eduardo Frei.

"A new spirit of unity must run through this nation," Lagos said. "We must overcome inequality, providing the same opportunities to every child in this nation. The past century left us . . . sadness [and] unresolved pains. It leaves us a lesson that we need to protect everyone's rights and dignities, and especially defend human rights as the basis of our community." In a country where people were afraid to say Pinochet's name aloud just a few years ago, Lagos's speech was interrupted by the crowd chanting, "Try Pinochet! Try Pinochet!"

The ascension of Lagos, who is renowned here for going on national television during Pinochet's rule, waving his finger at the feared leader and telling him he must be held accountable for his human rights violations, takes the former dictator's international disgrace full circle, analysts said today.

In part, Lagos may have Pinochet, who is still widely disliked or feared in Chile, to thank for his win. Last week's decision by British doctors that Pinochet was too ill to withstand a trial in Spain may have given Lagos a last-minute boost.

Lavin, who had a slight lead in some opinion polls before the news broke on Tuesday, had gone out of his way to distance himself from Pinochet's legacy and to portray himself as a centrist. But the former military ruler's possible release may have reminded voters of the link between the two and renewed a general distrust of the militant right wing that had kept candidates of Chile's center-left Concertacion coalition in the presidency since 1990.

But the closeness of the vote, and the fact that Lavin did better than any right-wing candidate in modern Chilean history, underscored that while Chileans remain divided over Pinochet's legacy, other issues have taken precedence. Both candidates largely focused on how to lead Chile out of its first recession in 15 years and tackle high unemployment, poverty and crime.

The election was viewed as a bellwether vote in the region, where two major political forces in modern Latin America, the "new left" and the "new right," battled it out through Lagos and Lavin. Lagos, whose Socialists won the Concertacion primaries in a landslide last year, represents a changed left that has embraced a more centrist model.

The approach has made inroads in such countries as Argentina, Uruguay and Venezuela, calling for the "third economic way" that accepts the free market but calls for a greater state role, especially to cut the massive income gap between the rich and poor that has exploded in Latin America during a decade of rapid economic growth.

In Chile, which was considered a model free market economy in the developing world for much of the 1990s, today's election of a Socialist would emphasize the growing discontent over free-market reforms.

Lavin marketed himself as a changed rightist who was capable of bringing back a more aggressive management style. A member of the conservative Roman Catholic group Opus Dei, he staged a well-financed campaign on a platform that stressed zero tolerance of rising crime, government efficiency and a declining emphasis on "political issues" such as addressing the military's human rights abuses and deepening democracy. He, like Lagos, promised to focus on inequity and poverty.

CAPTION: Chile's President-elect Ricardo Lagos of the governing Concertacion coalition said "a new spirit of unity must run through this nation."