The Spanish government today opened the way for the outlawed Spanish Communist Party to take part legally in the country's political affairs for the first time in 40 years.

Although it was not clear whether the Comminist Party would accept the route to legitimacy that was approved by the Cabinet, the decision significantly alters the party's stature in the country and brightens its political future.

After the death of dictator Francisco Franco 14 months ago, Henry A. Kissinger, then U.S. Secretary of State, urged Spanish King Juan Carlos to delay legalization of the Communist Party. But since last summer, the concessions to the Communists despite opposition by entrenched rightists here.

The Cabinet decision, announced in a royal decree after a day-long meeting, abolished a law giving the government the power to refuse to register a political party.

It shifted the responsibility for legalizing parties to the Supreme Court, which now must rule on applications not initially accepted by the Interior Ministry. There was no indication how the court would rule, but the court includes judges who are liberal.

It was not clear whether the Communist Party will decide to go to court, but if it does and wins a favorable ruling, Communists would be able to participate legally in government and politics for the first time since the Civil War in the 1930s, when they shared power in the Republican government. If registered, they could run for office and publish newspapers.

The rightists who ran Spain during Franco's lifetime considered Communists the country's greatest enemy and the party was banned during that period.

It has been tolerated since Franco's death but remains technically outlawed under the penal code because it is considered an "international party" dedicated to revolution and under the control of the Soviet Union.

The case for the Spanish Communist Party will likely be aided, however, by its advocacy of "Eurocommunism" and independence from Moscow and Kremlin directives.

Santiago Carrillo, the party's general secretary, announced today that a meeting would be held here soon as the leaders of the Spanish, French and Italian Communist parties, the leading advocates of Eurocommunism. The Spanish government, however, has not yet authorized the meeting.

The Cabinet decision was less than the opposition anticipated, but it was a major concession by Premier Adolfo Suarez, who has pledged to hold free parliamentary elections by spring. Most opposition parties, which refused to register unless the Communists are legalized, were awaiting the text of the degree before decidin whether to apply for registration.

The Cabinet also discussed restoring diplomatic relations with the Soviet Union, broken after the Civil War. An announcement that ties will be resumed is expected in a few days. In the past two weeks Spain has established formal diplomatic relations with four Communist countries - Yugoslavia, Romania, Bulgraia and Poland.

In recent weeks the Spanish press has published many stories on the increased activities of Eastern European and Soviet intelligence agents in Spain as a result of the increase in trade between Spain and Communist nations.

The reports appeared part of a campaign to delay establishing diplomatic relations with the Soviet Union, which would increase not only Soviet influence.

Nonetheless, the government is exchanging ambassadors with four Communist nations, and Spanish diplomatic sources said tonight that relations with the Soviet Union are "imminent."

A top Spanish foreign official was in Moscow two weeks ago to iron out final details, such as Spain's claim to the Republic's gold that aid for Soviet weapons during the Civil War.

Spain's opening to the East and increasing tolerance of the Communists is part of an overall move to alter its on Western European models with a Spanish flavor. The basic purpose is to be invited eventually to join the Common Market.