Two years after gaining power in an electoral landslide, Spanish Prime Minister Felipe Gonzalez has brought his left-wing Socialist Party round to prowestern defense positions and to monetarist orthodoxy in economic affairs.

During a four-day party convention that ended today, Gonzalez, 42, steered the Socialists toward accepting Spain's membership in NATO and gained backing for an austere government economic policy that has focused on reducing inflation and the budget deficit at the expense of climbing unemployment.

Gonzalez, a charismatic politician, was reelected party leader unopposed. At the middle of his four-year term, he told his party it would win again in "two years." The convention was the first since the Socialists took office after gaining 202 seats in the 350-member Congress in October 1982. Gonzalez emerged triumphant in what had been viewed as a key test of his personal ascendency over the party.

"There is no alternative to Gonzalez," said the leader of the Socialist labor union, Nicolas Redondo, who has been critical both of the government's western alignment and of its economic policy.

The convention marked what political commentators termed the "maturity" of the Socialist Party. Gonzalez, in closing remarks to the delegates, praised them for their "responsibility" in policy debates.

Previous conventions have denounced the military blocs and advocated neutralism. On economic questions, the Socialists traditionally have called for public ownership and a planned economy.

The party program adopted today gave Gonzalez the green light for remaining in NATO and accepted his austerity measures -- which have included salaries pegged below price rises and cutbacks in such money-losing state enterprises as steel and shipbuilding -- were accepted as necessary for economic recovery.

Gonzalez took a leading role in the major debates, outlining challenges for a European socialist movement in the closing years of the 20th century. These, he said, had little to do with traditional left-wing platforms and should, instead, deal with "modernizing" and "regenerating" society with "compassion."

"We were not called upon to govern so that we could distribute scarcity and hunger," Gonzalez said.

Gonzalez used the same approach to answer the anti-NATO lobby that sought to reaffirm the party's traditionally neutral policy in defense questions. He said the defense budget of neutralist Sweden was proportionally twice that of Spain.

In opposition, Gonzalez had campaigned against membership in the North Atlantic Treaty Organization as Spain was joining it in 1982. In the electoral campaign less than six months later, Gonzalez pledged that if the Socialists won they would ask Spaniards in a referendum whether they wished to remain in NATO.

At the convention, Gonzalez helped defeat a motion that would have committed the party to campaign in favor of withdrawal.