Spain's newly elected Socialists have reemphasized their determination to limit the country's participation in NATO or eventually to withdraw from the alliance entirely, and to rework a U.S.-approved defense agreement under which a 12,000-man American air and sea force is stationed here.

Defense is one of several foreign policy areas where the incoming Spanish government may run afoul of the wishes of the Reagan administration, according to party leaders interviewed before and after the Socialists' overwhelming election victory Thursday.

The Socialists said they also expect to "reexamine" the slated Spanish purchase of 84 U.S.-made F18 jet fighters. They hope to increase Spain's profile in Central America, which Washington views as within the U.S. sphere of influence, and to strengthen ties with Arab and nonaligned states in pursuit of overall neutralism.

The Reagan administration publicly has welcomed the results of the election, and has expressed a "wait-and-see" attitude on what the Socialists say about NATO and the bases agreement. But sources here said the administration has told the outgoing Spanish government that the proposed policy changes in the defense area are unacceptable.

"We want a very good relationship with the United States," Fernando Moran, a career diplomat considered a leading candidate to be foreign minister, said in an interview today. "It is one of our highest priorities."

The Spaniards are considered far to the "moderate" side of the spectrum of Western European Socialists, describing even the French party led by Francois Mitterrand as to their left. They are strongly anticommunist and the party shares, outside of the subject of NATO, most of the foreign policy views of West German's Social Democrats.

But the Socialists say they represent the views of most of Spain's citizens, including the right, in feeling more secure outside the superpower blocs.

While Socialist leaders emphasize that Spain is firmly in the Western world, and will, as Moran said, "do nothing to decrease the ability of the West to defend itself," they say they do not believe in supporting the "militarization of political thought" through blocs like NATO and the Warsaw Pact.

"We have never been opposed to NATO," the incoming Socialist premier, Felipe Gonzalez, said in a recent interview. "What we are against is Spain's joining NATO."

Like the Greek Socialists led by Andreas Papandreou, the Spanish Socialists have promised a nationwide referendum on NATO membership. But like Papandreou once he came to power a year ago, Gonzalez said the timing of the referendum is "not a priority."

More immediate problems will remain, however. Although Spain officially entered NATO last June, talks had only begun on its military role in the alliance system late last summer when they were suspended until after the elections. At the same time, Spanish congressional ratification of a new, five-year U.S. defense agreement, negotiated within the NATO framework, also was postponed.

Spain and the United States have had such an agreement, which now allows U.S. use of four Spanish naval and air bases and the permanent stationing of 12,000 men since 1953. But the Spanish government, under dictator Francisco Franco and his successors, repeatedly but unsuccessfully had sought to extend the agreement to include a U.S. defense guarantee for Spain.

Supporters here of Spain's entry into NATO, and other NATO members including the United States, pushed membership in the alliance in part on grounds that such a guarantee would come under the NATO umbrella. At the same time, it was argued, a Spanish presence in NATO would give the conservative Spanish military "something to do" to keep it out of domestic politics.

The Socialists agree that NATO membership could help modernize the 240,000-member Army. But they and even some officers believe that Spain's military does not see its principal role as that of outside defense. Most Spaniards appear to feel their country has little to gain and much to lose, in terms of its historically neutral status, through bloc politics.

Throughout the lead-in period for NATO membership and negotiations over the bases, the Socialists argued that any bilateral arrangements negotiated as part of the NATO framework would have to be reworked if they came to power.

The Socialists now say that all talks over a Spanish military role in NATO are frozen and that the bilateral agreement, which also earmarks more than $400 million in U.S. military assistance over the next year, must be altered.

"We don't say 'renegotiated,' " Moran said, "because the United States has a position and we want them to be able to save face." Additionally, the agreement, which the Spaniards call a treaty, already has passed through the U.S. Congress without objection as is.

What the Socialists would like, he said, is to modify the agreement to "clarify and make stronger" provisions that Spain be informed of and have some veto power over U.S. use of the bases for stopover flights to an ongoing destination.

For example, the Socialists are concerned that possible U.S. resupply of Israel, via Spain, in the event of future Middle East conflict could damage their relations with the Arab world. Such concerns are not new to the left here, and Franco prohibited such landings during the 1973 Israel-Egypt war.

The Socialists also would like a full bilateral defense guarantee from the United States, covering all territory including the Spanish enclaves of Ceuta and Melilla on the Moroccan coast. It is an issue that has always been difficult, since Morocco claims sovereignty over the enclaves, and the United States is unlikely to want to antagonize King Hassan II.

Once the agreement is reworked, Moran said, the Socialists feel they should have the option, if Spain decides to stay in NATO, of limiting their military participation in the same way as France, which does not belong to the NATO military structure.

The Socialists know much if not all of this is unacceptable to the United States, and even to many allies in Europe. But Moran described it as a "bargaining position."

Moran and other leaders have expressed concern that close relations with the United States may not be quickly or easily attained, in part because of a lack of contact between the United States and the Socialists that they blame primarily on the U.S. Embassy here that negotiated the defense agreement this year.

The embassy declined to comment for publication on what a number of prominent Socialists said. But there is general agreement here that the Americans have shown little interest up to now in making contact with the Socialists despite their growing political strength over the past several years.

Many in the Socialist leadership agreed with the experiences of Jose Maria Maravall, a leading party theorist, published in the United States, who also is expected to be in the Gonzalez Cabinet. "I've been in just about every embassy in this city this year," Maravall said. "But I don't even know what an American diplomat looks like. You'd think they would have called up even once."