A visiting high-level Soviet Communist Party official and Santiago Carrillo, general secretary of the small but influential Spanish Communist Party, appear to have worked out an ideological truce aimed at avoiding a confrontation over Euro communism during next month's Moscow celebration of the 60th annivessary of the Soviet revolution.

Communist sources reported that Victor Afanavsiev, member of the Soviet party's central committee and editor of the party newspaper Pravda, told Carrillo in a meeting last week that Soviet President Leonid Brezhnev wanted to reduce tension between the two parties and to open discussions on theoretical differences raised by the Spaniard in his book "Eurocommunism and the State."

Carrillo's work sparked virulent Soviet condemnations when it was published in the summer.

Afanavsiev and Carrillo discussed the ground rules for the dissident Spanish Communist leader's visit to Moscow for the anniversary celebration for nearly an hour in the party's headquarters here, sources said. They were accompanied by aides and drank a toast afterward.

Brezhnev apparently wanted Carrillo to attend to Moscow festivities, but did not want it marred by any discordant ideological notes, sources indicated. Carrillo in turn sought assurances that he would be neither embarrassed nor gagged while in Moscow.

Afanavsiev came to Madrid last weekend with a small Soviet delegation to attend a Communist Party festival which attracted an estimated million people - not all of them Communists. The turnout and the apparent acceptance of Carrillo by both the Spanish govenment and the Spanish people as a leading political figure seemed to have impressed Afanavsiev.

The Pravda editor's talk with Carrillo was influenced by "what he saw," Communist said.

Ever since it became known that Carrillo was going to visit the United States next month for talks at Yale and Havard, the embassies of Communist countries which support Carrillo's position have rallied around him.

Spanish Communist consider the U.S. trip a tremendous political boost in Spain, a party spokesman said, "because it helps to erase the image" created by the Francisco Franco dictatorship that "we were killers."

There is no doubt that the Soviet Union is also aware of the U.S. visit's political implications not only in Spain but in the Communist world. Afanavsiev rather clumsily warned last week that if the Spanish leader attacks the Soviet Union in the United States the Kremlin will resume its offensive against Carrillo.

But the Spanish communist leader appears to be riding high at home and abroad. His moderation in delicate negotiations with Premier Adolfo Suarez, his wit in parliamentary debate have earned him praise even from staunch Spanish anti-Communists.

A recent poll showed that party strength has gone up from less than 10 per cent in the June 15 election to 12 per cent. Party officials attribute the gain to "our moderation."

Despite Carrillo's attacks on the Soviet system, the Kremlin has not stopped trying to win influence among Spanish leftists and to undermine the maverick Communist leader. It shipped a planeload of propaganda for distribution at the weekend Communist rally, and it keeps up a steady flow of Soviet visitors in an attempt to influence Spaniards and enhance the image of the Soviet Union.

There are indications that while Soviet officials grudgingly accept Carrillo's leadership, the Kremlin still has hopes for his rival. Enrique Lister, a 1936-39 civil war general who is waiting for a visa to return to Spain.

The Spanish party, outlawed by Franco at the end of the civil war, did not become legal until April. Carrillo was in exile for most of that period. He returned clandestinely last fall and was arrested at the end of the year but held only briefly.