Spain's Supreme Court set a legal precedent of far-reaching political consequences today when it drastically increased sentences handed down by a military court last summer on the officers who attempted to overthrow the government in February 1981.

Among those receiving stiffer sentences was Gen. Alfonso Armada, the Army's deputy chief of staff at the time of the coup attempt, who was given a six-year term last June and will now serve 30 years.

The Supreme Court's decision marked the first time here that a court-martial decision had been tested by a higher civilian court. Since the establishment of a separate code of military justice at the turn of the century, Spain's legal tradition had been that only the military could pass judgment on itself.

The new sentences followed an appeal to the Supreme Court, brought by the prosecutor general under new rules in the military code, against an original ruling by a court-martial bench of 17 generals. That ruling was widely criticized at the time for its leniency toward the rebels.

A panel of seven Supreme Court judges upheld the prosecutor general's plea that six senior officers, among them Gen. Armada, were guilty of military rebellion rather than conspiracy to rebel as the court-martial had ruled. The changed verdict meant that in addition to the maximum sentence for Armada, who was condemned as a coleader of the coup attempt, the original sentences on the other five, which had ranged from between three and six years, were increased to between six and 12 years.

In all, 22 sentences against 30 defendants were increased by the Supreme Court. Lower-ranking officers who played minor parts in the coup attempt had their sentences increased from three years to five and from two years to three. As a result, some officers who had been released after serving their terms will now return to prison.

The Supreme Court overturned acquittals against eight lieutenants who, the court-martial had ruled, had "followed superior orders." Seven lieutenants were given one-year sentences and one a two-year term.

The Supreme Court also upheld the 30-year maximum sentences that the court-martial had handed down on Gen. Jaime Milans del Bosch and Civil Guard Col. Antonio Tejero. Milans had declared a state of siege in the eastern Valencia region that he commanded at the time of the coup attempt, while Tejero led the dramatic Civil Guard takeover of the legislature and held it hostage for 17 hours. Lawyers for the two had lodged countersuits against the sentences before the Supreme Court.

By overturning verdicts reached by the court-martial--which had sat as the supreme military court when it judged the rebels last summer--and by drastically increasing sentences and reversing acquittals, the Supreme Court appeared to have dealt a body blow to the military justice system. Civilian critics have charged that the system, in its present form, is anachronistic and at odds with the Spanish constitutional concept of a single, uniform judicial system.

The decision also seemed to underline a new self-confidence that Spanish society has gained in the wake of the Socialist Party's landslide victory in national elections last October. A striking feature of the changed atmosphere is an absence of the civilian nervousness over possible military plotting that has characterized much of Spain's political transition to democracy.

Reacting to the Supreme Court's ruling, Premier Felipe Gonzalez said it had "closed a chapter in Spain's history in an extraordinarily clear manner." A government spokesman called the ruling "the end of a painful and tragic episode."