Baltimore State's Attorney Kurt L. Schmoke, a 37-year-old city success story who represents a new generation of political leadership, won Baltimore's Democratic Party primary yesterday and is all but certain to become the city's first elected black mayor.

In a race that was supposed to be a rout and turned into a cliffhanger, Schmoke eked out a victory over Mayor Clarence H. (Du) Burns. Schmoke won 51 percent of the vote, according to unofficial returns, and ended the long political career of Burns, the former City Council president who ascended to the mayor's office when Gov. William Donald Schaefer took office in January. At one point in the race, polls showed Schmoke with a 30 percentage-point lead.

The elections officially close the Schaefer era in Baltimore, where the popular mayor had ruled the city since 1970. In choosing a successor, Baltimore Democrats overlooked Schaefer's endorsed candidate and chose Schmoke, a politician independent of the organizations that have dominated city government. In fact, Schaefer does not even like Schmoke.

Despite beautiful late summer weather, only about 35 percent of the city's Democrats turned out to vote, according to the city administrator of elections. The small rate was attributed to a mayoral campaign that lacked specific differences on issues.

Samuel A. Culotta won the Republican nomination, but Baltimore is a Democratic town. With registered Democratic voters outnumbering Republicans nearly 10 to 1, the Democratic primary is tantamount to election. The general election is Nov. 3.

In a seesaw race, Schmoke trailed Burns for several hours after the polls closed at 8 p.m. But by midnight, the tide had turned. With all of the city's 437 precincts reporting, Schmoke had received 78,550 votes and Burns had 73,508 votes, or 47 percent. Four other candidates divided the remaining 2 percent.

There are 3,588 absentee ballots, not enough to change the outcome.

"We're looking to the future now," said Schmoke, who refused to claim victory until Burns conceded early this morning. On the prospect of becoming the city's first elected black mayor, Schmoke said, "We are moving slowly but surely to a time when people are judged by their character and not their color."

Burns was gracious in defeat, only smiling at his supporters' chants of "recount."

"One of the things about me, I could always count," Burns said.

He promised his support for Schmoke and thanked his supporters. "I've had a fantastic life in politics," Burns said. "I always believed that nobody came here to stay."

The next mayor will hold the reins of the nation's 11th-largest city, which under Schaefer experienced a rebirth of its downtown and a resurgence in city pride. But Baltimore is one of the nation's poorest cities, with declining blue-collar employment, a faltering education system, among the highest teen-age pregnancy and infant mortality rates in the country, a deficient health care system for the poor, and a crisis in low-income housing. The city is 55 percent black.

Burns maintained during the campaign that under his eight-month leadership the city already has begun to tackle the problems. Schmoke said new priorities for the city are needed.

The city's first all-black Democratic mayoral primary gave voters the choice between Burns, who worked his way up through the traditional, white-dominated political structure, and Schmoke, whose political base is the city's new black majority.

One television exit poll showed that Schmoke received 64 percent of the black vote while Burns received support from 61 percent of white voters.

Support also seemed to split along generational lines, with the majority of voters under age 50 siding with Schmoke and older voters preferring Burns.

In the race for City Council president, former council member Mary Pat Clarke -- who lost to Burns in the same race in 1983 -- relied on a grass-roots campaign to defeat state Del. Larry Young and former state senator Harry J. McGuirk, a Schaefer ally and old-style city politician. Comptroller Hyman Pressman, who has held the office for 24 years, won the nomination for a seventh four-year term. Voters also cast ballots for the city's 18 City Council seats.

The campaign to replace Schaefer was criticized as an issue-less affair, as both candidates pledged to improve the city's social services and schools while trying to build upon the economic rebirth fostered by Schaefer.

But there was a stark contrast in style. Burns, who turned 69 Sunday, is a veteran of the Baltimore civil rights movement and one of the first blacks in the city to create a political machine that came to be respected by the white political organizations that dominate the city's ethnic neighborhoods.

His climb took more than 40 years. Along the way he was a political deal-maker in his native East Baltimore and a locker room attendant at a black city high school. After serving on the City Council, he became the first black to be elected City Council president -- owing much of his 1983 victory to his loyalty to Schaefer and Schaefer's subsequent support.

During this year's mayoral campaign, Burns touted his closeness to Schaefer, at one point telling a crowd in almost biblical fashion that he "sat at the right hand" during the Schaefer years.

Burns, whose campaign was plagued by disorganization and insufficient money, nonetheless pressed Schmoke on what Burns called a lack of experience. In their only debate of the campaign, Burns frequently pointed out that Schmoke had never served in city government and was unfamiliar with governing.

"Mr. Schmoke, you don't know what you're talking about," was a constant refrain from Burns during the debate.

Schmoke, on the other hand, could not be goaded into saying anything negative about Burns. Some people involved in the campaign worried that Schmoke's cautious campaign style and his refusal to confront Burns allowed the mayor to reduce a lead that had seemed insurmountable.

Schmoke was in a way a beneficiary of Burns' generation of black leaders. He was quarterback of the football team of one of the city's best high schools and a star scholarship student at Yale University. He won a Rhodes scholarship to Oxford University, attended Harvard Law School and worked in a blue-chip law firm, the U.S. attorney's office and the Carter White House.

His victory in 1982 over the conservative white state's attorney -- a grass-roots campaign that resulted in a startling upset -- was seen as the first real assertion of the city's black voters. But he also received support from white liberals and professionals. Since then, Schmoke was looked at as the mayor for Baltimore's future, a theme he constantly returned to during the campaign.

If Burns is a product of the city's political machines, Schmoke is the antithesis. "I'm not looking to become the 1980s or 1990s version of {the late Chicago mayor} Richard Daley," Schmoke said, referring to Daley's grip of the political machines that ran the city. Instead, Schmoke said he would like to be more like Sen. Richard G. Lugar (R-Ind.), who as mayor of Indianapolis championed a regional form of government that merged the cities and suburbs.