Leaders of the three most important Communist parties in Western Europe today opened the first "Eurocommunist" summit meeting - here in the capital of Spain, where the Communist movement has been outlawed for 40 years.

Despite its continuing refusal to legalize the Spanish Communist Party for national elections due this spring, the government of King Juan Carlos turned a blind eye to the meeting in a luxurious hotel here.

The government did furnish the Communists with police protection against possible attacks. This morning a bomb went off outside the Justice Ministry, but there was no indication that it was connected with the summit conference.No one was injured by the blast.

The conference of Spanish Party leader Santiado Carrillo, France's Georges Marchais and Italy's Enrico Berlinguer is intended primarily as a boost to the Spanish Communists' campaign to win formal recognition from the government and a place on the ballot for the first national elections since Generalissimo Francisco Franco died in November 1975.

As the first session of the scheduled two-day conference got under way late this afternoon, local Communist sources said that Carrillo was also trying to get Berlinguer and Marchais to agree to a strong final communique that would implicitly back human rights and the dissidents in Eastern Europe and the Soviet Union.

These sources, conceded, however, that Carrillo's effort is not likely to succeed. Sources in the other delegations said that the three parties are still far apart on this and other issues, and that the French and Italian delegations do not expect new efforts here to expand the concept of Eurocommunism.

This term is used by political analysts to describe the three parties' movement away from the model of Communism and the seizing of power provided by the Soviet Union and Eastern Europe. The French, Italian and Spanish parties have all said they are trying to become mass parties that will come to power by the ballot box and retain individual and political freedoms as they are understood in Western Europe today.

The meeting of the three very different Marxist parties and their equally contrasting leaders, who have been at odds in the past, understored the new common interests the parties perceive in withstanding pressure from Moscow and helping one another to convince the respective electorates of their commitments to democracy.

Less than 18 months ago, Carrillo and Marchais were bitter foes. The French official Communist newspaper, L'Humanite, refused to interview the exiled Spanish leader, then living in Paris, and the French party - then closely aligned with Moscow - reportedly cut off its financial assistance to Carrillo after he sharply attacked the Soviet invasion of Czechoslovakia in 1968.

Today, Marchais grasped the Spanish party boss in a bear hug at the Madrid airport and joined Carrillo's demand that the party summit meeting be allowed to hold public sessions. The government has banned any public rallies but has indicated that it will not act against the private meetings.

"I brought a speech for a public rally in my briefcase," Marchais said, "and I have a press conference statement, too. You see, my dear Santiago, that I am ready," he added, using the French familiar form, "Tu."

Carrillo, who drove out to welcome Marchais in a black late-1940s model Cadillac limousine like those Spanish bullfighters use to drive to the ring, beamed as he replied that the conference would be a success "for democracy and for our parties."

Marchais' reference to his desire for media coverage indicated that the French Communists see the summit as a possible plus in this month's increasingly important nationwide municipal elections, and for the newly democratic image the French party, which has 500,000 members and takes about 20 per cent of the national vote, is trying to establish.

The Italian Communists, who as Italy's second-largest party hold an effective veto over all major legislation, appear to want little out of the conference beyond helping Carrillo establish his own credentials locally, where he has been under attack for his allegedly totalitarian and terrorist record in the Spanish Civil War.

It was to the Italians that Carrillo turned for support after the 1968 break with Moscow, and he and Berlinguer have worked out the shape of the Eurocommunist philosophy, which has been described as "socialism with a human face."

But Berlinguer - reportedly under pressure from militant labor union organizers and student groups in his party's left wing - has toned down party criticism of the Soviet Union recently. He is reportedly not eager to see the human rights issue become a major subject of discussion here.

On his fight from Paris to Madrid this morning, Marchais said the French party has spoken out against repression in any country, including the Soviet union, on a case-by-case basis but sees no need for a sweeping declaration by the three parties.

"We are coming to help the process of democracy in Spain, and to help our brother party," Marchais said. Asked for his opinion of President Carter's meeting with Soviet dissident Vladimir Bukovsky yesterday in Washington, Marchais said:

"We do not want to get involved in the business of other countries . . . But states and statesmen should do what they can to help those under repression. Our party does."

Tonight, the three leaders attended a dinner to which 25 Spanish party leaders, spanning the spectrum from center-right monarchists to leftist socialists, were invited. No government officials attended the dinner.

Carrillo returned to Spain illegally in November and was arrested in Madrid. The government released him in January and has made no moves against him or the party since then, although it rejected the party's request for legal status under new election laws.

The party is appealing the government decision to the Supreme Court, and the timing of the summit conference may also be related to the pending decision.