Spanish Prime Minister Felipe Gonzalez said today that talks on the reduction of U.S. troops and bases in Spain should start "as soon as possible" and that the issue would be raised in his meetings here next week with President Reagan.

The United States stations 12,540 military personnel at four bases in Spain under a 1953 agreement and consistently has indicated its desire to maintain those bases. Gonzalez's government agreed to a five-year extension of the pact in 1983 but since has spoken of a desire for reductions.

Gonzalez reiterated, in briefing American correspondents today, his public commitment to stage a referendum on whether Spain should remain in the North Atlantic Treaty Organization and his personal aim of seeing the plebiscite favor continued membership.

The prime minister stressed that membership meant a "new situation" for Spain, which joined NATO in 1982 before Gonzalez's election that same year. He said that membership implied a reduction in the need for U.S. military presence here and that negotiations would have to begin before the referendum on NATO membership scheduled for early next year.

The twin policy to shore up NATO links and to reduce those covered by an existing Spanish-U.S. defense agreement was spelled out by Gonzalez last October. He said he would explain the policy to President Reagan when they hold talks here on May 7.

The Communist Party, labor unions and pacifist and ecological groups plan anti-U.S. demonstrations for Reagan's arrival in Madrid from Bonn on May 6. Gonzalez said the president's visit posed "delicate" problems. "The demonstrations worry me, although not excessively. There will be demonstrations also in West Germany, although that is no real consolation," he said.

Gonzalez said, however, that the visit would be delicate mostly because the anti-NATO lobby in Spain would be given an excuse to claim that Reagan was pressuring the Spanish government into remaining within the western alliance. He said the possible public coolness toward the visit as well as the expected hostility from protesters would be balanced by the welcome that he and head of state, King Juan Carlos, would extend to Reagan.

Reviewing Spanish perceptions of the United States, Gonzalez said it was often forgotten "that the Americans did not liberate Spain in World War II , that Spain did not enjoy the fruits of the Marshall Plan" and that the bases pact "propped up the dictatorship" of Francisco Franco after the war.

Gonzalez, 43, took office in December 1982 after a landslide electoral victory by his Socialist Workers' Party -- the historic party of the Spanish left that Gonzalez built up during Franco's last years.

Asked whether he was concerned that the plebiscite would be against NATO, Gonzalez answered "yes." He said that should the vote be against the alliance, he would be obliged to withdraw from NATO. Polls have indicated that a majority oppose the alliance.

Gonzalez argued that a reduction of U.S. presence in Spain would generate public support for his pro-NATO policy. He described a package including a commitment that Spain would ban nuclear weapons and, although a member of NATO, would not be part of the alliance's military command.

There are four U.S. bases in Spain -- technically they are Spanish bases on which the United States is granted facilities -- with 12,540 military and 1,660 civilian personnel. The major bases are the Rota naval depot, at the entrance to the Mediterranean, which is a key logistical center for the 6th Fleet, and Torrejon, close to Madrid, where 79 combat aircraft are stationed.

Gonzalez did not specify the size of reduction he was seeking. "The U.S. presence will be reduced to the level that is required by the strategic interest of Spain and by that of the West," he said.

"Americans might think that U.S. soldiers here are making a sacrifice and favoring Spain and that we are not grateful," Gonzalez continued. "Perceptions here are different, and it is a question of foreign troops on our soil." He said that the different perceptions were in contradiction and that an equilibrium had to be found.

Gonzalez's views appear to clash with U.S. interests, particularly since the proposed reduction is not to be accompanied by a direct Spanish military contribution to NATO.

Since Gonzalez raised the issue last October, there has been a broadly negative response from Washington. The Rota depot and the Torrejon base are presented as being essential, as is an air base near Zaragoza that is the main firing range for U.S. combat aircraft stationed in Western Europe. The base at Moron, near Seville, is seen as providing valuable real estate.

Asked if the intent was to reduce the number of bases, Gonzalez replied affirmatively, noting as an example that "Moron was once important but does not seem so important now." The base houses 390 military personnel and 45 civilians. Fifteen air-refueling tankers are based there, along with a naval communications transmitting station.