The Communist government of Cuba has signaled a new willingness to end its long confrontation with the Roman Catholic Church and other religions.

The shift in recent months has not softened the atheistic, Marxist doctrine on which President Fidel Castro has built his rule for a quarter century. But it has created what Archbishop Jaime Ortega of Havana called "a new spirit" and "a sense of opening" that have enhanced the prospect of coexistence between religous faithful and party faithful.

"It will take time, during which we will have to do away with the past, create new relationships and change attitudes on both sides," Archbishop Ortega said in an interview. "What has been built up during the last 25 years is a mentality that will not change easily."

Diplomats stationed here said the government's effort to ease tensions with the church stems in part from a campaign to win broader acceptance in Latin America. The Catholic hierarchy traditionally has been a strong influence in most Latin countries.

Cuban officials said the changes also reflect increased willingness by the Cuban hierarchy to live within the revolutionary system Castro has set up.

The most concrete step taken by Castro's government so far has been the creation in January of the Religious Affairs Office headed by Jose Felipe Carneado, a member of the party's powerful Central Committee. Carneado, 70, called himself "an old Communist" and nonbeliever but declared in an interview that the government and the church "are no longer in the era of confrontation."

Carneado said one of his main tasks is "to make explicit the government's policy of respecting people's consciences." To do so, he added, he has had to intervene to reverse decisions at lower levels denying entry into a coveted school to children of religious parents, for instance, or denying a new car to a churchgoing worker who had earned it by exemplary performance on the job.

Such instances of discrimination against believers were part of what led the U.S. State Department to conclude in this year's human rights report, covering 1984: "Although the constitution asserts that there is freedom of religion in Cuba, the practice of religion is actively discouraged."

Things have changed with the opening of his office, Carneado said, and with "official concern to give more attention and more systematic attention to problems of the church and religions."

One problem is numbers. Despite Cuba's Catholic tradition, the number of Catholics who regularly attend Sunday mass has dwindled to 75,000 and there are only 215 priests, although 40 percent of Cuba's 10 million inhabitants are baptized, Archbishop Ortega said.

In addition, Cuba has about 100,000 members of Protestant faiths and 1,200 Jews, authorities estimated, along with thousands of Cubans who practice the African-influenced rites of santeria. By comparison, Carneado estimated that the Cuban Communist Party has half a million members and another half million in the party youth movement.

Castro, whose gestures set the tone for most of what happens here, first signaled the relaxed atmosphere last summer during a visit by the Rev. Jesse Jackson, then a presidential candidate. Castro accompanied Jackson to a Methodist church in Havana and then, to the surprise of many, went to the pulpit and gave a short talk.

The Cuban leader merely expressed his pleasure at Jackson's visit, and Carneado joked that it was "the shortest speech of his life." But the sight of Castro inside a church and formalizing his presence with an address marked a departure in a country whose government has been wrangling with religious leaders almost since its inception.

Then, at the beginning of this year, Castro received a delegation of U.S. bishops and invited Cuba's religious hierarchy to an official reception for the visiting prelates.

"This was an extraordinary, exceptional thing," smiled Carneado, recalling the sight of bishops, nuns and monks clinking glasses with the Communist Party and government hierarchy.

One measure of how exceptional was the reception was that a major accomplishment of the U.S. bishops' visit was a pledge by Castro to meet formally with Cuban bishops for the first time to "deal directly with Cuban bishops on church problems," Archbishop Ortega said.

The prelate said no meeting had been arranged yet, but he expects that an encounter will take place "at the appropriate time." In any case, Castro maintained the relaxed spirit by attending a dinner in May given by the papal nuncio in Cuba, the Rev. Julio Einaudi, in honor of his counterpart based in Nicaragua, who was visiting Cuba.

Carneado asserted that the Cuban church has become easier to deal with in part because the hierarchy has changed from the early days when, he said, older prelates actively opposed Castro's revolution and subsequent government.

Archbishop Ortega declared that, with few exceptions, Catholics had supported Castro's struggle against dictator Fulgencio Batista and, in any case, have been ready for dialogue for some time. In a sermon June 23 to an archdiocesan assembly, he said he wants the Cuban church "to move from silent tolerance or mere acceptance to full participation, without demogogy or triumphant tones but also without hidden shames."

Dr. Jose Miller, an oral surgeon who is president of the Jewish Community House in Havana, said authorities also have shown willingness to improve the religious lives of Cuban Jews. Carneado has discussed allowing rabbis to visit and officiate at holiday services, improving care of a Jewish cemetery and opening a kosher restaurant, he said.

Carneado said he also has opened talks on the possibility of a full-time rabbi here. But the government reserves the right to screen applicants to make sure their ministry will not clash with Cuba's official anti-Zionist stand, he added.