The Socialist Party of Spanish Prime Minister Felipe Gonzalez won an absolute majority in parliament today, giving Gonzalez a second four-year term.

With 96.6 percent of the votes counted, the Interior Ministry reported Gonzalez's party had won 44 percent of the vote and could be expected to hold 184 seats in the 350-member Congress of Deputies, the lower house of Parliament.

"A new era is beginning for Spain in which our nation will have to confront several challenges: Complete integration into Europe, further economic growth and more jobs and the modernization of our society," Gonzalez told supporters late tonight. "I call on everyone to join forces to make these national objectives reality."

The returns gave the Socialists 18 fewer seats than the 202 seats they won in the 1982 elections, but the result was comfortably ahead of the 176 needed for a majority in the legislature.

The main conservative opposition group, the Popular Coalition, won about 26 percent of the vote and an estimated 105 seats in Congress. In the last election, the coalition won 107 seats.

Gonzalez's victory is likely to be greeted with satisfaction in Washington and in other western capitals. The Spanish prime minister gained the respect of the allies when the voters approved his support for continued membership in NATO in a March referendum.

Over the past four years Gonzalez has consistently opted for moderation and for enhancing links with the West to bring Spain out of the tensions and the isolation that marked the nation's contemporary history under the 40-year dictatorship of Gen. Francisco Franco. Today's general election was the fourth since Franco's death in 1975.

A high point of Gonzalez's first term was Spain's entry into the European Community at the beginning of this year. During the past two years there has been a significant increase in foreign investment in Spain, reflecting growing confidence in continued political stability under the Spanish leader.

The chief gains in the elections were made by small parties. The centrist Democratic Social Center party led by former prime minister Adolfo Suarez, increased its strength in Congress from two seats to 19.

The Communist-led coalition, that won four seats in 1982, won seven seats tonight. There were gains also among the nationalist parties in the Basque country and in Catalonia.

The Interior Ministry estimated the turnout of 29.2 million voters at 70 percent, down from the 80 percent of the voters who turned out four years ago. Holding of an election on a Sunday for the first time could have contributed to the higher abstention rate. Officials said the election was marked by calm.

The result for the Spanish Socialists was in contrast to the fate suffered over the past nine months by sister socialist parties in neighboring France and Portugal, and it elevated the status of Gonzalez, 44, in Western European social democratic circles.

Although both Portugal and France have socialist presidents, the socialist parties have in recent elections lost their majorities in the legislatures of both countries.

Gonzalez's victory was a vindication of the moderate policies he pursued during his first term. The Socialist government put a priority on coping with the economic crisis and on ensuring democratic stability. Voters appeared to have responded to the prime minister's campaign claims that conditions have been created for sustained economic growth and that his principal achievement had been the consolidation of democracy following Franco's four-decade dictatorship.

In part, Gonzalez's success can be attributed to the failure of his opponents to provide a credible alternative, analysts and observers said. The failure of the conservative Popular Coalition to make any inroad in the Socialist majority marks a major setback for rightist politician Manuel Fraga Iribarne, a 63-year-old one-time minister under Franco who has until now been the indisputable leader of Spanish conservatives.

Although the essential feature of today's vote was the clear hold that Gonzalez's Socialist Party has over Spaniards, secondary themes were the indications of a shift toward the left within the Spanish electorate and of an increased support for nationalist parties.

The gains by the Communists reflected an element of dissatisfaction over the prowestern policies adopted by Gonzalez. Last March the prime minister, who had once been hostile to Spanish membership in NATO, won a referendum to endorse continued membership in the alliance.

A second element of dissatisfaction concerns the high unemployment rate in Spain, which is officially put at 22 percent of the labor force, or 3 million people, and is the highest in Western Europe. Employment has been one of the chief casualties of Gonzalez's austerity policy and his cuts in public spending.

Former prime minister Suarez, whose Democratic and Social Center emerged as the third national party, campaigned on a radical reform platform that called for greater government control over private banks, improved relations with the Third World and cuts in the U.S. presence in Spain.

In Catalonia, as in the Basque country, local nationalist parties, whose politics revolve around the demand for greater autonomy from the central government, increased the percentage of their vote. The Catalonia-based Convergence and Union increased its number of seats from 12 to 18. In the Basque country, the extreme nationalist group Herri Batasuna, the political front for the ETA terrorist organization, was expected to win five seats against the two it won in 1982, officials said.