Madrid — The visit of United States Defense Secretary Caspar Weinberger to Spain this week is part of a continuing American effort to draw the two countries into a closer relationship while bolstering NATO's military strength.
The Weinberger trip - the first of a US defense secretary since Spain joined the Atlantic alliance last year - follows recent calls on the new Socialist government of Prime Minister Felipe Gonzalez by Secretary of State George Shultz and other high-ranking US officials.
At stake are US diplomatic efforts in Latin America and the Middle East (regions in which Spain has considerable interest), as well as the Reagan administration's attempt to build broader and stronger European support for countering what it perceives as a troubling military buildup by the Soviet Union.
Prime Minister Gonzalez is walking a fine political line on questions of full integration of Spain into the NATO military structure as well as bilateral agreements with the US on the basing of American military forces here. Thus, the American diplomatic effort is, by design, low-key and friendly as well as firm and direct.
Before his election last October, Mr. Gonzalez campaigned against Spain's entry into NATO, and said if elected he would hold a referendum on the subject. Since then he has cited fragile East-West relations as reason enough not to weaken the Western alliance by holding a referendum now.
Recent polls show that most Spaniards (61 percent) favor leaving NATO. But this may have more to do with the failure so far of the European Community (EC) to invite Spain in. France has been holding out, fearing that Spanish agricultural imports could damage the French economy while West Germany favors admitting Spain to the group.
Observers here say once that roadblock is removed, questions of the NATO referendum and eventual integration of Spanish forces into the alliance's military structure are likely to be resolved.
''The sense here among diplomats is that the government is not at all interested in taking Spain out of NATO,'' says a US official in Madrid. ''With the passage of time, the issue could just slip from public concern.''
There is little question but that the new bilateral agreement between Spain and the United States will be approved by the Spanish Parliament before May 21, when the existing agreement expires. This includes a sharp increase in US-funded scientific, educational, and cultural exchanges.
It allows some 8,500 American military personnel to remain at Spanish air bases at Zaragoza and Torrejon and at the naval base Rota. And it also retains Spain as one of the top recipients of US military training for its forces.
This training (as well as arms sales agreements on such weapons as the F-18 fighter and new ships) is necessary if the Spanish armed forces are to progress beyond their traditional role as protectors of internal security.
The new defense minister in the Socialist government, Narcis Serra (a young man with a full beard), apparently has won the respect of the military, and reforms are under way.
Spanish officials hope their emergence into the Western alliance will hasten a resolution of the sovereignty of Gibraltar.
There also have been increasing talks here of Spain's role as the ''mother country'' for Latin American nations and possible assistance in relieving instability there.
The US sees Spain as increasingly important for development of the Rapid Deployment Force and its ability to reach the Middle East quickly if needed. Spain has particularly close ties with Arab countries in that region.