WHAT Czechoslovak President Vaclav Havel called "the wheel of history" has spun so rapidly during the last few days that heads here are reeling. The president's phrase came in reaction to news of the Soviet coup Monday morning, which, he said, "reminds us of very sad events more than 20 years ago at the same time of year."Wednesday marked the 23rd anniversary of the Soviet invasion that crushed the Prague Spring reforms of 1968. This is only the second year that Czechoslovakia has been free to commemorate the day as a tragedy and not as a Soviet propaganda event. News of Soviet leader Mikhail Gorbachev's overthrow just two days prior had stirred unhappy memories and new fears for Czechoslovakia's fledgling democracy. Now there is relief as Czechs, along with other East Europeans, have seen the Soviet coup disintegrate. But before that wave of relief, the hastily established state defense council, headed by Deputy Interior Minister Jan Ruml, fortified the nation's eastern border in anticipation of a possible wave of refugees. Though Mr. Ruml appealed for calm, he said, "We must take measures to ensure that it would be impossible to again wake up some misty morning and find ourselves occupied by foreign armies." Jumpy Czechoslovak motorists raced to the gas pump for fear that the flow of oil from the Soviet Union, their main supplier, would dry up. Three-hour petrol queues spilled out onto highways, causing traffic jams, and factory workers huddled around transistor radios during breaks to hear the latest bulletins from Moscow. But Wednesday afternoon news that coup leaders had fled reached tens of thousands of people gathered in Prague's Wenceslas Square. The solemn demonstration called to commemorate the 1968 invasion and protest the Soviet coup ended in jubilation, reaffirming Czechoslovakia's commitment to democracy and economic reform. "The last two days have put our own problems into perspective," said Jan Petranek, a journalist from the leading independent newspaper Lidove Noviny. Mr. Petranek has vivid memories of the 1968 Soviet invasion, during which he and a small team including current Foreign Minister Jiri Dienstbier kept up three days of resistance radio broadcasts from a secret post in Prague. For the first time in many months the bickering between leaders of the Czech and Slovak republics halted, at least temporarily, and top Slovak officials joined Czech counterparts in exhorting crowds in Prague and other major cities to stick to reform and support the common state. "The events in the Soviet Union should focus minds here. Slovakia has to wonder if it really wants to be a tiny country alone in the shadow" of such chaos, a Western diplomat said. The eastern republic of Slovakia shares a 90 kilometer border with the Soviet Union. At a time of growing disenchantment at petty personal disputes between politicians that have slowed passage of crucial legislation, the unity and civic initiative shown at the Prague rally filled citizens with pride. The crowd sang, wept, and cheered as representatives from a broad political spectrum gave speeches of solidarity with Soviet citizens and support for democracy at home. Czechoslovakia will need an extra measure of good will in coming months. The harsh impact of economic reforms and new societal problems of crime and unemployment, as well as larger worries about the nation's security and its role within Europe contribute to growing unease. This acute awareness was in many minds even during Wednesday's demonstration, which ended with the arrival of several hundred members of the extreme-right-wing Republican Party chanting crude slogans against President Havel. The spontaneous reaction of the crowd revealed that the president's efforts to encourage tolerance and conciliation have strengthened his role as defender of national unity. As the Republicans approached the edge of Wenceslas Square, a deafening cry went up like a shield against them: "Long Live Havel."