Prime Minister Felipe Gonzalez, once an avowed opponent of Spanish membership in NATO, called on Spaniards in a nationwide broadcast today to support continued presence in the western alliance.

Gonzalez was answering questions in a televised interview, and his stand was viewed as the opening shot in a campaign backing the alliance prior to a referendum on the membership issue scheduled for early next year.

The prime minister again linked Spain's continued membership in the North Atlantic Treaty Organization to a reduction in U.S. military personnel stationed here under a bilateral defense agreement. He also said that Spain would not be integrated into NATO's military structure and that a current ban on stockpiling of nuclear weapons in Spain would remain in force.

Gonzalez said he was "certain" that the U.S. troop reduction would be achieved "through negotiation" but added that if this were not the case, Spain would insist unilaterally on a reduction. He did not say what degree of reductions he was seeking.

There are about 12,000 U.S. military personnel in Spain, most of them at a Navy depot in Rota, at the entrance to the Mediterranean, and at an Air Force base at Torrejon, near here.

The 15-minute interview with the prime minister, which was prerecorded, was likened by a senior Spanish official to the "starting pistol" in the forthcoming referendum campaign.

Gonzalez said the plebiscite would be in mid-March, but he did not specify the date. He said that a parliamentary debate on Spain's defense priorities would be held in late January or early February and that 30 days would then be set aside for referendum campaigning.

Public opinion polls have indicated that a majority of Spaniards oppose NATO membership. Spain formally joined the alliance in June 1982 under a previous center-right administration and at a time when Gonzalez, who leads the Socialist Party, was in opposition. Gonzalez was strongly hostile to NATO entry, organized rallies against the move and promised, in subsequent campaigns that swept his party to power, to hold a referendum on the issue.

Explaining his change of views, the 43-year-old Gonzalez said Spain's role in the world was better served by NATO membership, which also was a "plus factor" in technological development.

But the key explanation for the turnabout appeared to be linkage between NATO and membership in the European Community, which Spain is scheduled to join Jan. 1 after long negotiations that were completed earlier this year.

"In order to take part in the construction of Europe, we have to share the destinies of nations like France, the United Kingdom, the Netherlands, West Germany," Gonzalez said. He argued that participation in Europe on an economic level had to be accompanied by a contribution, through NATO, to European peace and security.

Gonzalez said he was confident that the Spanish people were sufficiently "mature" to endorse continued membership and assume the "responsibility" of freely deciding on national defense interests.

Gonzalez appeared to be making a specific appeal to Spaniards to endorse him personally on the NATO issue, and thus to be relying on his continued high popularity.