Lech Walesa won the first round in presidential elections but, in a startling upset, Prime Minister Tadeusz Mazowiecki was shut out of next month's runoff by a wealthy, enigmatic emigre.

Mazowiecki met with his government to decide whether to resign, and a secretary in his office said a decision would be announced Monday night.Walesa, the favorite in Sunday's balloting, had 39 percent of the vote with all 49 provinces reporting.

The emigre businessman, Stanislaw Tyminski, won 23 percent to Mazowiecki's 18 percent, according to provincial election commission results reported by the official PAP news agency. Three minor candidates split the rest. About 60 percent of eligible voters cast ballots.

It was a stunning setback for Mazowiecki, the East bloc's first non-Communist head of government, who during 15 months in office had spearheaded an economic "shock therapy" reform program.

Mazowiecki had said he would quit as prime minister and move into political opposition if he lost the election.

It was unclear whether he would support his former Solidarity ally, Walesa, in the runoff.

Walesa told reporters at Solidarity headquarters in Gdansk Monday that he is "hesitating" about contesting the Dec. 9 runoff with Tyminski and said he does not consider him "a serious man."

"I wouldn't like to run, but one has to think over what is good for Poland," Walesa said. "For the last 10 years, I was at the helm of Polish reforms. There were victims and sacrifices and it wouldn't be proper to leave it now."

The election, Poland's first popular presidential vote, was the first in Eastern Europe to focus not on defeating communism but on choosing between visions for the post-Communist future.

The new president will take over from Gen. Wojciech Jaruzelski, who ordered martial law to crush Solidarity and imprisoned Walesa and Mazowiecki in December 1981. Jaruzelski is retiring early to complete the democratic transformation. The new president will be elected to a five-year term.

Tyminski, a 42-year-old virtual political unknown, returned to his homeland this fall after 21 years in Canada and Peru.

He apparently impressed Poles worn by economic hardship and the political scrap that split Solidarity. The free-spending head of the fringe Libertarian Party of Canada has promised Poles a quick cure for their economic woes and accused the government of incompetence.

Tyminski was confident Monday.

"I will win these elections," he said as he arrived at his headquarters. "I want to want to make this country rich and prosperous. It will be better within a month."

He said he knows "people in Warsaw who are already dying of poverty and hunger" and offered to provide addresses when challenged by reporters.

Walesa, a shipyard electrician who as Solidarity leader marshaled the forces that ended four decades of Communist rule, has said it would be "horrible" to face Tyminski in a runoff.

He has described the emigre as "a man straight from the bush," an apparent reference the challenger's experiences in Peru's interior.

In the country's largest newspaper, Gazeta Wyborcza, commentator Piotr Pacewicz attributed Tyminski's showing to "a second Poland" of disaffected rural and small-town voters. He said Tyminski backers were enticed by this man "who arrived `clean,' from outside the situation . . . who came from the world of success, from the Americas."

An exit poll by state television indicated that farmers, who represent 40 percent of Polish society, deserted Mazowiecki en masse, angry at the abolition of guaranteed prices for their produce. Mazowiecki also fared poorly among workers, winning only among intellectuals.

Dr. Zofia Kuratowska, a pro-Mazowiecki senator, compared Tyminski to "pseudo-medical swindlers . . . People trust them, and not the real medicine." Mazowiecki was a longtime adviser to Walesa, who last year tapped Mazowiecki to become head of the government. But they had a bitter falling-out, and the voting climaxed an often acrimonious campaign that splintered Solidarity.

The charismatic Walesa, 47, had contended that Mazowiecki was too slow in his reforms and called for ridding the government and industry of Communists.

Mazowiecki, who has cautioned against "witch hunts," accused Walesa of destabilizing the country. The 63-year-old prime minister argued that Poland needs his team to stay and finish the job through consistent, gradual change.

He has accused Walesa of making promises he cannot keep, and some of his backers say Walesa would be a demagogue.