In August 1990, a young member of the new Bulgarian parliament, Solomon Passy, proposed that Bulgaria quit the Warsaw Pact, the military alliance of the Soviet Union and its satellites, and join instead the North Atlantic Treaty Organization. "The idea was absolutely scandalous," Passy recalled earlier this month with a grin. His own party immediately disowned him. The Communists who still ran the country dismissed his suggestion.

Passy told this story in the office of the Bulgarian foreign minister -- which he now happens to be. He knew that next month, NATO will formally invite Bulgaria into the alliance. This fact, still quite astounding to Passy and many other Bulgarians, was one reason for his grin. It constitutes a happy ending to a kind of fairy tale for a country of 7.6 million that is about to become a member of the world's most reassuring club, one that promises to defend its members' security in all circumstances.

Bulgaria's transformation from most loyal Soviet satellite to disastrously unsuccessful new democracy to prospective member of NATO demonstrates how quickly history has moved -- especially since Sept. 11, 2001. Not that the invitation happened by chance. Passy is one of numerous Bulgarians who worked hard over many years to qualify the country for NATO membership, but until last year there was no clear sign that their efforts were about to succeed.

Acting on the proposition that "if you want to become a member of NATO, behave as if you are one," as Passy put it, Bulgaria quickly offered the United States whatever help it could provide after the terrorist attacks. U.S. tanker planes refueling aircraft for the Afghanistan campaign used a Bulgarian air force base at Burgas on the Black Sea for two months, a real contribution to the war effort, according to American officials.

The Bush administration was grateful. "We realized," said a senior U.S. official, "that we need as many allies as we can get" for the war on terrorism. Bulgaria and its larger neighbor to the north, Romania -- which sent a battalion of troops to Afghanistan -- soon found themselves moved from doubtful to likely candidates for the next round of NATO enlargement, which will be formally announced at a summit meeting in Prague in a few weeks.

Bulgaria had been on the doubtful list because its transition from communism to democracy and free markets had been painful and, for most of the first decade, unproductive. As recently as early 1997, the country was on the verge of economic collapse; inflation that February was 243 percent for the month, the gross domestic product was plummeting and Bulgarians were lining up to buy bread. Former Communist functionaries had run the country into the ground.

A government elected that April finally put Bulgaria on a path toward stability. An independent currency board controlled inflation. New leadership began a radical reduction in the size of the armed forces and pushed Soviet-era commanders into retirement.

Not that the country's problems have all been solved. Bulgaria remains a struggling new democracy, its people profoundly discouraged by a persistently low standard of living and high unemployment. Politics are wildly unpredictable, corruption and organized crime are common, and the ghosts of communism still hover. Asked in a recent poll if they looked to the future with hope or anxiety, 65 percent of Bulgarians surveyed said "anxiety."

One symbol of Bulgaria's unusual situation today is its last czar, Simeon II, who is also the current prime minister, under the name Simeon Saks Koburgotski. His appears to be the only case of a former king winning popular election to become prime minister of his country.

Saks Koburgotski is a Bulgarization of his real name, Simeon Saxe-Coburg-Gotha. His family, originally German, is related to virtually all the royal families of Europe. Simeon sat on the Bulgarian throne from 1943 to 1946, between the ages of 6 and 9, a reign that began when Bulgaria was an ally of Nazi Germany. Exiled for the entire Communist period, he married a wealthy Spanish woman and lived in Madrid, raising five children.

When the Communist government fell, Simeon (as everyone here seems to call him) began toying with a return to Bulgaria. In the late '90s, he decided he would run for the largely ceremonial position of president, which amounts to being a kind of elected king. Tall and slim, with a close-cropped beard and an aristocratic bearing, he was wildly popular when he traveled about the country. Women kissed his hand and called him "your majesty," which he didn't seem to mind.

But the constitutional court blocked him from running for president, because five years' residency was required and he had only a few weeks'. So Simeon, 65, created a new political party and entered the 2001 parliamentary elections. He quickly patched together a slate of candidates for parliament consisting of some established figures such as Passy and a number of unusual choices, including the girlfriends of businessmen of dubious repute and a fashion model.

His timing was excellent. The sitting government of the Union of Democratic Forces had saved Bulgaria from economic disaster in 1997 but by 2000 was extremely unpopular. Living standards remained low, corruption was rife, and the UDF prime minister, Ivan Kostov, had earned a reputation for arrogance.

Simeon ran a vaguely populist campaign, promising a cure to the country's ills within 800 days. Barely three months after it was created, his party trounced the field, winning more than half the vote. Suddenly, Bulgaria had a new prime minister from Spain -- a man who "has no idea how Bulgarian society functions," according to a minister of the previous government. Even his Bulgarian was antiquated.

Simeon's traditional political skills are nonexistent. He reads his speeches awkwardly and avoids questions. When trapped by a reporter he is likely to respond, "I'll answer that later."

Simeon's cabinet has stuck to the economic and foreign policies of the previous government, a relief to the United States and other NATO members. Politicians and foreign diplomats agree he doesn't seem to enjoy being prime minister. "He complains how tired he is," said one journalist.

With his 800 days more than half over and many problems remaining unfixed, he has lost half the support he had in the June 2001 election, according to public opinion polls.

The former czar is Topic A in Sofia, the capital, but outside of town his name is not mentioned so often. An excursion to Pernik, an industrial city to the southwest, presents a different reality. The smokeless smokestacks towering above the town are the first clue.

"This was the biggest industrial center in Bulgaria," lamented Assen Petrov, 48, an engineer laid off by the local water company who now sells Turkish- and Greek-made shoes from a forlorn storefront downtown.

Now the city's factories are mostly shuttered. The unemployment rate in Pernik is at least 60 percent. Unemployed men sat in outdoor cafes on a recent Saturday drinking vodka and wine.

"I don't even want to talk about my country," said Petrov, unsmiling and unshaven in front of his shop. "Do you see any future in this country? I don't." He has a daughter studying at a university in Sofia, but has advised her, "when you get your degree, just leave the country," as nearly a million young Bulgarians have.

A similar disillusionment came from a farmer who would give his name only as Radenko and who said he was 73. He works as a watchman in the village of Trudovets, northeast of Sofia, on a state farm that is lying fallow. The steel frames of vast greenhouses covering about 25 acres suggest the farm's former significance.

"We grew vegetables for the Russian market," Radenko explained. But the glass on the greenhouses has been shattered or stolen, and nothing has grown in them for years. The state farm collapsed because there was no market for its products, and younger people didn't want to work in the fields, he said.

"The blue evil ones destroyed everything," he continued, referring to the previous government, whose color was blue. Old and bent, using a walking stick to try to straighten his back, Radenko gestured around the abandoned farm. "Every single politician is a thief," he said. He offered a sentimental recollection of life under Todor Zhivkov, Bulgaria's Communist dictator for 35 years until 1989. "Zhivkov took care of everything," he said. "Now there's no real government taking care of the people."

Not far from Trudovets is Pravets, Zhivkov's home town. A new statue to him was unveiled recently; the Defense Ministry sent an honor guard for the occasion. That infuriated the anti-Communists of the UDF.

The UDF's Philip Dimitrov, a former prime minister and ambassador to Washington, criticized Simeon for cultivating ex-Communists and refusing to say anything critical about more than 40 years of Communist rule. Others criticize the former czar for maintaining relations with some of Bulgaria's darker business figures, former Communists and secret policemen.

Although many Bulgarians have high hopes about the impact NATO, and later, European Union, membership will have on their country, many remain gloomy about the future. "Hopelessness is the biggest psychological problem we face," said Dimitrov.

Ivan Krastev, director of the Center for Liberal Strategies, said his polling has found that 20 percent of Bulgarians could be characterized as "winners" from the post-Communist transition, based on their upward mobility, income, consumption and other factors.

But only 5 percent are willing to call themselves winners, he added. This gap is explained, he said, by the fact that Bulgarians today think people succeed only by being crooked, and that successful people are looked down on by the public. He called the 15 percent who did not acknowledge their success "closet winners."

"Somehow we have to get those people out of the closet," Krastev said, to help build the solid middle class that long-term stability will depend on. Perhaps admission to NATO would push some of them into reevaluating their situations, he added, by legitimizing Bulgaria's success as an evolving free-market democracy and encouraging successful Bulgarians to acknowledge their accomplishments. "If we can't get them out of the closet in the next five years," he added, and break the cycle of pessimism and cynicism, Bulgaria will face "big trouble."