In 1983 ministers of the revolutionary Sandinista government lined up on the tarmac to welcome Pope John Paul II on his first visit to Nicaragua. Moments later, TV cameras showed the pontiff wagging a finger at the kneeling Ernesto Cardenal, priest and minister of culture, admonishing him for mixing religion and politics.

But for Cardenal, who has died aged 95, there was no distinction between the two. His beliefs as a Roman Catholic growing up in Central America in the 1940s and 50s led him to seek social justice in a country that had for many years suffered under the dynastic rule of the Somoza family. His faith also meant he could not avoid political responsibility if it was thrust upon him.

The bridge between these two sides of Cardenal’s life was his poetry. As he said in a 1970 interview when asked about his writing: “I have expressed one reality, which is political, economic, social, religious and mystical all at the same time.”

It was Cardenal’s poetic vocation that first showed itself. Born in the provincial city of Granada in western Nicaragua, he spent his childhood in León, the other university city in the country. As a youth he began writing love poems, heavily influenced by the Chilean poet Pablo Neruda. From 1943 to 1947 he studied abroad, at the National Autonomous University in Mexico City. While there, in 1946 he brought out his first volume of poems, La Ciudad Deshabitada (The Uninhabited City). In the same year, his anthology of contemporary Nicaraguan poetry was published in Spain. He also helped start a venture to publish cheap editions of classic texts.

Cardenal spent the next two years at Columbia University in New York City, where, among other work, he wrote the long poem Raleigh, in which, for the first time, he explored the shared history of the peoples of the American continent before and after its conquest by Europeans.

By the time of his return to Nicaragua in 1950, Cardenal had founded a new poetic movement, exteriorismo. This, in its choice of images from the everyday world, showed that he was decisively on the side of those writers who rejected “pure” poetry and wanted their work to have a social dimension. Part of his literary output at this time came in the form of aphorisms.

Many of them called for revolt against the Somoza dynasty, landing Cardenal in jail for a short period in 1952. His commitment to action as well as literature led to his participation in the failed April 1954 uprising against the dictatorship, which marked him deeply and permanently.

In 1956 Cardenal experienced his religious conversion. “God simply showed himself to me as love,” was how he explained it. In May 1957 he became a novice at the Trappist monastery of Our Lady of Gethsemani in Kentucky, in the US, under the guidance of the poet and philosopher Thomas Merton. His life there is reflected in the collection of poems Gethsemani, Ky, published in 1960. The stern Trappist regime took its toll on Cardenal’s health, however, so that after two years he moved on to a Benedictine monastery in Colombia. He was ordained in 1962. His major book of poems from these years is Zero-Hour, published in Mexico in 1960, as were his Epigramas the following year.

Cardenal returned to Nicaragua as a priest, and then embarked on what in many ways was his most enduring achievement: founding a religious community among the peasant farmers and fishermen of Solentiname on the island of Mancarrón in Lake Nicaragua. The community was established in 1966, and, as well as literacy and poetry workshops, soon became famous for its naive paintings and tapestries.

In 1970 Cardenal underwent what he saw as another conversion: a three-month stay in revolutionary Cuba convinced him that Marxism offered the best way forward for social justice. He saw no contradiction between this and the kind of primitive Christian community he was developing in Solentiname, even producing a liberation theology version of the New Testament: El Evangelio en Solentiname (The Gospel in Solentiname). His 1960s poetry appeared in collections such as Oración por Marilyn Monroe (Marilyn Monroe and Other Poems, 1975), in which he used collage, multiple voices and other modernist techniques to convey his message.

In 1977, following an attack on a national guard barracks in the nearby town of San Carlos, the settlement at Solentiname was razed to the ground in reprisal. Cardenal himself was forced to flee into exile in Costa Rica, where he became one of the Group of Twelve – a dozen core members of the Frente Sandinista de Liberación Nacional (FSLN) coordinating the Sandinistas’ international efforts.

He returned in triumph to Nicaragua in July 1979 when the FSLN toppled Anastasio Somoza from power, and was immediately appointed minister of culture, with headquarters in Somoza’s former mansion. Again he saw no contradiction between his political work – which included a publishing venture and the creation of poetry workshops everywhere from coffee plantations to army units – and his religious duties. The pope and traditionalists in the Roman Catholic church saw things differently, however, and in 1984 he was suspended from the priesthood.

The Sandinista government’s attempts to alleviate poverty, distribute land and bring radical change to all levels of one of the poorest countries in Latin America quickly brought it up against the US president Ronald Reagan. He financed the rightwing Contra rebels, who opposed the Sandinista government and soon stifled the gains of the revolution in a bloody civil war.

In 1987 Cardenal resigned as minister of culture, in part because of the climate of war, and also because of personal rivalries within the Sandinista movement. He returned to Solentiname, and after the Sandinistas were voted out of power in 1989 was one of those who became disillusioned with the lack of transparency and democracy within the movement. Instead, he backed the Movimiento de Renovación Sandinista (Movement for Sandinista Renovation), which found little favour with the voters.

He was increasingly at odds with the administrations led by Daniel Ortega since 2007. In 2017 the Nicaraguan supreme court ordered Cardenal to pay close to $800,000 over disputed land transactions in Solentiname. Although this ruling was never enforced, Cardenal considered himself a “political prisoner”, arguing that Ortega and his family were determined to persecute him. He was a vocal supporter of the widespread protests that broke out in 2018 against Ortega’s increasingly authoritarian rule.

Although he was able to write little poetry as a minister, his later work, including Los Ovnis de Oro (The Golden UFOs, 1988) returned to themes of the shared history and identity of the native peoples of America. His work was increasingly recognised internationally: he was nominated four times for the Nobel prize in literature, and in 2012 was awarded the Reina Sofia prize for Ibero-American poetry. Weakened in recent years by illness, he nevertheless published two new collections of poetry: Así en la Tierra Como en el Cielo (On Earth As in Heaven, 2018) and Hijos de las Estrellas (Children of the Stars, 2019).

Most gratifyingly for Cardenal, in February 2019 Pope Francis lifted the ban on him practising as a priest, declaring in a personal letter to him that he was “absolved of all canonical censure”.

The community Cardenal created at Solentiname continues to prosper. The members produce paintings of the lake, its birds and other wildlife, and pursue the vision of a utopia in this world to which Cardenal dedicated his life.

• Ernesto Cardenal Martínez, priest, poet and politician, born 20 January 1925; died 1 March 2020