The left-of-center Party of the Brazilian Democratic Movement suffered a surprise upset in the nation's largest city, where the right-wing populist candidate Janio Quadros won by a small margin in Brazil's closely watched municipal elections.

Victory by a margin of about 130,000 votes for Quadros, 68, a former president whose resignation in 1961 led directly to the 1964 military coup, was described as "a black cloud in political terms" by Democratic Movement rival, Sen. Fernando Henrique Cardoso, who conceded defeat at a televised news conference at his home tonight.

"This will give an archaic, Ku Klux Klan tone to national politics. President Jose Sarney had better look out," Cardoso had told reporters when the loss began to appear likely earlier tonight.

Anxious not to strain his fragile political coalition, Sarney had avoided taking sides in the conflict.

With 89 percent of Sao Paulo's 4.5 million votes counted tonight, Quadros led with 37.8 percent against Cardoso's 34.2 percent of the vote. Today, the Gallup Institute predicted a 38 percent vote for both candidates and said the election was too close to call.

Democratic Movement analysts were quick to blame the defeat on a split vote caused by the rapid rise of elected Workers Party candidate Eduardo Suplicy, with 19.5 percent of the vote. But the Workers Party was also set to overtake the Democratic Movement in Goiania, another state capital.

Seven months as senior partner in the ruling coalition that supports Sarney took its toll. "This period in government has cost the Democratic Movement 5 to 6 percent of the vote," said political scientist Dolizar Lamounier.

The municipal elections in 23 state capitals and 178 other towns previously under direct administration were the first elections since Brazil's return to civilian rule in March. About 20 million people voted.

Expected victory in at least 16 of the 23 state capitals for the Democratic Movement -- which formed the backbone of resistance to the old military regime and is Brazil's largest party -- was badly undercut by the defeat in Sao Paulo, the party's headquarters.

With an anticommunist law-and-order message capitalizing on the city's high crime rate, Quadros repeated the populist tactics that catapulted him from the city mayor's post to the presidency in 1961.

He avoided head-to-head debate with rivals, and refused to provide details of his proposed administration. His chief campaign tool was the household broom -- carried by supporters as a symbol of his promise to sweep away lawlessness and corruption.

Supported by the Liberal Front Party, junior partner in the ruling coalition, Quadros promised a much more conservative tone to the Cabinet, and a ministerial reshuffle is likely. His overt Liberal Front backers are Energy Minister Aureliano Chazes and Foreigh Minister Olavo Setubal.

But Quadros also received discreet support from the former military government's economics minister, Antonio Delfim Netto, and its defeated presidential candidate, Paulo Maluf.

Such an expressive vote against the "new republic" in favor of old political values will have repercussions in forthcoming stages of Brazil's return to full democracy.

Cardoso had said the Democratic Movement's chances in next November's congressional and state elections would be affected adversely by a Quadros victory.

"If Quadros becomes mayor here, almost certainly the Democratic Movement will fail in 1986 state elections," he said. "If this occurs, the basis for redemocratization will be undermined."

"Ex-president Quadros has become a rightist populist leader," said Cardoso. "In the past, he was different, but nowadays he represents law and order and violence -- he even urges summary justice. This isn't traditional in Brazil, where our conservatives are more civilized."