BRIEFLY, WHILE a fanatical colonel who had already attempted one coup held the full parliament at gunpoint, King Juan Carlos became the sole custodian of democracy in Spain. He responded magnificently, showing not only a devotion to principle but also a consummate political skill, thereby preserving public calm and staying the hand of almost all of the officers who might have been tempted to return the army to power.

The attempted coup was at once widely taken as a brutal exposure of what sober people had known all along -- that the democratic system that replaced the Franco dictatorship five years ago still lacks a secure institutional base and full public confidence, and that it cannot be counted on to deal effectively with the normal range of social and economic stresses and with the special problems of the autonomy movements and terrorism.

It is true that elements in the armed forces and economy that undergirded Franco's rule still exist and still are strong. The "events of Feb. 23," however, can surely be taken as just about the most strenuous test of Spain's democratic affinities that anyone could devise.Unquestionably, Spain passed.

The king's role was the most dramatic. How ironic that the links to the military -- he was schooled by Generalissimo Franco and attended all three military academies -- that once made him suspect here gave him the credibility and connections that enabled him to act as he did. With a few exceptions, the officers also proved themselves faithful to the new order. Whether it was their discretion or their sense of duty or their institutional self-interest is somewhat beside the point. As for the civilian politicians, they were all under the same gun. Some sat proudly upright in their chairs; others dived under their desks. Conservatives, Socialists and Communists alike emerged from their common ordeal unharmed and insisting that democracy must be strengthened in Spain.

Spain's fellow Europeans, especially in the north, have never stopped demanding, explicitly or implicitly, that Spain redeem its fascist past by showing itself worth of democracy. These invisble yet real bonds of obligation have been accepted by many Spaniards as reinforcement of their own desires. But obligations run both ways. The other Europeans have understood the value of rising above short-term practical objections and tying Spain ever more closely to Europe in order to nourish its political order. The feeling underlies the readiness to make a place for Spain in the Common Market, and in NATO, too.