Prime Minister Felipe Gonzalez announced today that Spain would buy U.S.-made F18A Hornet fighter-attack planes for its Air Force, but reduced the number to 72 from the 84 originally ordered by the previous government in Madrid.

The Spanish decision represents the first sale to Europe of the McDonnell Douglas combat planes, which also have been offered to Greece and Turkey. The prime minister's announcement came after weeks of doubt during which Madrid assessed a "European option" represented by the Tornado combat aircraft, which is jointly built by West Germany, Britain and Italy, as an alternative purchase.

The original order for 84 Hornets had been placed last summer by the centrist administration then ruling Spain. In December, after winning national elections, Gonzalez signed a letter of intent for the purchase and deposited $10 million as a nonreturnable down payment with the deadline for the letter of acceptance set at May 31.

Gonzalez's new Socialist government, however, simultaneously said that it would restudy the Tornado and officials said the aim was to promote industrial links with Western Europe. The Tornado had been rejected by the Spanish Air Force command when it completed its reequipment study in 1981.

Gonzalez told reporters the decision to reduce the purchase by 12 aircraft would save Spain about $360 million.

Last summer's original deal was budgeted at $3 billion, but the prime minister did not specify the new overall cost nor what terms had been set for transfer of the technology to Spain.

For the Pentagon, the long-expected sale is good news from both policy and economic standpoints, Washington Post staff writer George C. Wilson reported.

Defense Secretary Caspar W. Weinberger has been trying to strengthen Spain's ties to NATO, and a supply relationship for military hardware is one way to do it.

On the economic side, the sale of F18s abroad will cut the price per aircraft for the U.S. Navy because of the savings from large production runs. The rising cost of the F18 has been of concern to Pentagon executives. Navy Secretary John Lehman had estimated that an 84-plane order by Spain would save the Navy $300,000 for each plane it buys.

The F18A Hornets will replace Spain's aging Phantom and F5 fighter-bombers, some of which are more than 20 years old and saw service in Vietnam. Under the newly announced terms of the reequipment program, by the early '90s the Spanish Air Force would fly six Hornet squadrons and 72 French-built Mirage F1s.

The final decision announced today represents Spain's largest single arms purchase, and there had been intense lobbying here by the three-nation Panavia consortium which sells the Tornado as well as by McDonnell Douglas.

Billing itself as the "European alternative," Panavia appeared to meet the goverment's hopes for greater technological integration with Western Europe by offering Spain's national aerospace industry a minority shareholding in the consortium.

The bargaining for the Spanish contract was heightened by what industry sources said was the possible spinoff effect of Madrid's decision on Greece. The Greek government is currently considering offers for the purchase of up to 100 combat aircraft.

Earlier this month West German officials, who have been prominent in the Panavia lobbying, publicly accused the Spanish government of simulating interest in the Tornado solely to gain better terms from McDonnell Douglas. The Spanish Air Force, for its part, has stated in a succession of communiques that the Hornet was its favored choice because of its all-purpose combat characteristics.