Madrid — Time has officially run out for Spain and the United States to reach a definitive agreement on use of American bases in Spain.
An eight month extension of the 1976 friendship and cooperation treaty expires May 21 and as of May 20 a definitive text was still not ready.
If the treaty is not signed, the United States will have to dismantle its air bases in Madrid and Zaragoza and the naval base of Rota within a year, according to Article 8 of the present treaty.
Throughout the week and all day May 20 US and Spanish delegates have been working feverishly to eliminate remaining obstacles in a race against the clock.
Although both sides claim there are only ''secondary problems,'' Spanish diplomatic sources have indicated that problems remain over the touchy question of ''respect for Spanish sovereignty.''
The Spaniards continue to object to indiscriminate use of the bases by either the United States or NATO forces in a conflict involving another country with whom Spain maintains friendly relations.
Spain has insisted on the right to veto when Spanish interests don't coincide with American or European interests. The Falklands crisis, in which Spain has joined ranks with Latin America rather than Europe, has dramatically illustrated the importance of this argument.
Many Spaniards do not wish to endanger long standing friendly relations with South America by a hypothetical support or back up use of the bases in the Falklands conflict or another South American crisis.
A future Middle East war has also been cited as an example where American or NATO interests may differ from Spanish ones. As of May 20, Spain's ''veto right'' had still not been ironed out.
Other snags were reportedly solved May 20. The most controversial involved the amount of economic aid the United States was to grant Spain in exchange for use of the bases. Spaniards had termed the 1976 amount as ''ridiculous.''
American sources have indicated that the present amount is three times as much, although Spanish newspapers have pointed out that this economic aid really amounts to loans at only a slightly lower interest rate than internationally available rates.
A three-fold increase in economic aid will not have to be approved by the US Senate as the present treaty will be downgraded to ''agreement' status, similar to those the United States maintains with other NATO countries.
Spain is due to join NATO probably before the next alliance meeting in Bonn on June 10. Treaty negotiations had been extended for eight months because both sides wanted to wait until Spain's entry in NATO was settled.
A third problem delaying signature of the agreement involves the possibility of the United States storing nuclear arms on the joint Spanish-US bases. Spaniards refuse to accept nuclear arms in Spanish territory ''until the Spanish government decrees otherwise,'' according to Spanish sources. This condition was apparently accepted by the US delegates Thursday.
In spite of frantic last-minute negotiations over the sticky points in the negotiations, US Embassy sources were still optimistic that an agreement could be signed on schedule.
''In any case,'' said an American spokesman, ''its not the end of the world. We won't have to start dismantling the bases immediately and an agreement can be reached a few days later.''
Theoretically, another extension would need both Spanish parliamentary and US Congressional approval. However, both sides feel that some sort of ''technicality'' can be summoned up to drag out the marathon negotiations a few more days if the agreement is not signed today.
US Secretary of State Alexander M. Haig Jr. had wanted to stop over in Madrid May 18 on his way back to Washington from the Luxembourg NATO meeting, apparently to speed up talks and force an early signature.
But talks were then hopelessly stalemated and he had to cancel the Madrid stop. Other sources have implied that part of the negotiating difficulties are not so much between the United States and Spain but rather between the Spanish Foreign Affairs Ministry and the Spanish Defense Ministry.
Both Spanish ministries refuse to comment. Spanish diplomatic sources had estimated the chances of signing an agreement May 21 as ''50-50'.