Hungary's ruling Socialists have appointed Ferenc Gyurcsany, a flamboyant millionaire, as the country's new prime minister. The new prime minister, if confirmed by the parliament early next month, will bring a new generation into Hungary's politics.

Mr. Gyurcsany, who was not even in contention for the job a week ago, emerged as the clear winner at Wednesday's extraordinary Socialist Party congress, where he beat his main rival, Peter Kiss, for the top job. He will replace Peter Medgyessy, who was ousted by his party.

Hungarians hope the new appointment will end a political crisis that began last week when Mr. Medgyessy fired the economy minister of the Socialists' liberal coalition partner, the Alliance of Free Democrats, as part of a government reshuffle.

The firing angered not only the Free Democrats, but Prime Minister Medgyessy's own party as well, which dumped him within hours of the announcement.

In an interview with Hungarian state television, Mr. Medgyessy said he felt betrayed by his fellow Socialists. He says, "when I was invited to the Socialist Party Congress to be their prime minister, we made a kind of agreement that people make when they get married." He says the party made a promise to stay behind him in good and in bad times. Unfortunately, Mr. Medgyessy says, "I received only half of that promise. The Socialists only stayed with me in the good times and dumped me when the situation started to be difficult."

His successor, Mr. Gyurcsany, will inherit an unpopular government and a growing budget deficit, which analysts say may hamper Hungary's efforts to adopt the European Union common currency, the euro.

The 43-year-old prime minister, who became rich buying state assets during the early years of Hungary's privatization, is widely seen as representing a philosophical break from the old-guard politicians of the Communist era, embracing both a liberal business outlook and support for social justice.

The Free Democrats have said they will accept Mr. Gyurcsany as the new prime minister. But gaining public support, says analyst Tamas Kiss, of the energy news service Platt's, will be more difficult, especially at a time of rising prices and an uncertain economic outlook. "Household energy prices are increasing. The government is selling and privatizing MOL, the national oil and gas company as much as it can," he says. "So people are really concerned."

Hungary is not alone among the former Communist countries of central Europe in going through political upheavals. Since May, the prime ministers of Poland and the Czech Republic have also been forced out of office after losing popular support.