HAVANA – Cardinal Jaime Lucas Ortega y Alamino, the former archbishop of Havana who helped organize the first papal visit to the communist country and negotiated modest openings with a government that was once officially atheist, has died. He was 82.

His death was announced by his successor, Archbishop Juan de la Caridad García Rodriguez.

Ortega also was the intermediary who helped open a dialogue between Havana and the U.S. that led the two countries to resume relations in 2014, after presidents Raul Castro and Barack Obama secretly turned to Pope Francis for help. It was later revealed that he served as a messenger for both sides, carrying secret letters and responses that helped thaw relations.

With his flawless French, flowing vestments and dark-rimmed glasses, Ortega cut an elegant figure in Cuban society. Abroad, he was well known among fellow cardinals, especially in the United States, where he befriended several, including Cardinal William Keeler, archbishop of Baltimore.

Born and raised in Cuba, the country's top Roman Catholic leader was mentioned at times as a longshot candidate to succeed Pope John Paul II.

But Ortega's beginnings were modest, and his climb up the ecclesiastical ladder was arduous.

The son of a sugar worker, Ortega was born on Oct. 18, 1936, in the sugar mill town of Jagüey Grande in the central province of Matanzas, and moved to the provincial capital as a child. There, he attended public schools and began studying for the priesthood at San Alberto Magno Seminary.

He completed his studies with the Fathers of Foreign Missions in Quebec, Canada, and returned to Matanzas to be ordained on Aug. 2, 1964 -- just as the new communist government was further weakening an already feeble Cuban church.

The church, long identified with Cuba's wealthier citizens, took a vehemently anti-communist line shortly before Castro declared Cuba to be socialist in 1961. The government later accused prominent Catholics of trying to topple Castro.

Cuba's Cardinal Jaime Ortega celebrates Good Friday mass during Holy Week in the cathedral in Havana, Cuba, April 6, 2012.

Public religious events were banned after processions were transformed into political protests, sometimes turning violent. Hundreds of foreign priests, mostly from Spain, were expelled. The more than 150 Catholic schools that once operated across the island were nationalized.

Ortega was among many Cuban priests sent to military-run agricultural work camps, spending a year beginning in 1966. After his release, Ortega worked as a parish priest in his hometown. He also oversaw several neighboring parishes, traveling among churches to say Mass, perform baptisms and officiate at weddings.

A practiced pianist, Ortega composed music for a Cuban Catholic Mass, and traveled to Havana weekly to lecture on theology at the San Carlos y San Ambrosio Seminary.

Ortega was named bishop for the western province of Pinar del Río in December 1978 and was consecrated the following month. He became archbishop of Havana in November 1981.

At the time, the Cuban government was officially atheist. Believers of all faiths were banned from the Communist Party, the military and some other professions. But Ortega quietly helped rebuild the church infrastructure around Havana, establishing new parishes and renovating more than 40 churches.

He also set up Caritas of Havana, the first office of the Catholic relief charity in Cuba. That planted the seed for Caritas of Cuba, which delivers meals and medicine to people across the island.

"Today we think of Cardinal Jaime with affection and gratitude. He will remain with us with memories of his smile, clairvoyant intelligence and his committed and sometimes afflicted priesthood," said Havana's current Archbishop Monsignor Juan de la Caridad Garcia.

Ortega was named president of Cuba's Catholic Bishops Conference in 1988 and held that position for a decade.

In November 1994, Pope John Paul II named Ortega the first cardinal in Cuba in more than three decades -- and the second in the island's history.

In 1992, the government dropped its constitutional references to atheism, and a gradual thaw in church-state relations began, culminating with the papal visit on Jan. 21-25, 1998, and government acceptance of some outdoor religious events.

While Ortega refrained from publicly confronting the Cuban government, on his trips abroad he expressed disappointment that the opening had been modest.

Critics accused him of being too conciliatory to the government, although Ortega -- who in 2010 and 2011 helped the church and Raul Castro reach a deal to free a group of political prisoners who had been held since 2003 -- said the church's place was not in politics but in humanitarian deeds.

In an official statement, the Cuban government said, "His tireless pastoral work and his love for Cuba led him to decisively strengthen relations between the Roman Catholic Church and the state."

Cuba's Cardinal Jaime Ortega, right, stands behind Pope Francis in the popemobile as they arrive for mass at Revolution Plaza in Havana, Cuba, Sept. 20, 2015.

In April 2016, Pope Francis approved Ortega's request to retire.

Ortega's funeral is expected to take place at Havana's Cathedral, where he preached as archbishop for many years.