Father Ernesto Cardenal, a Nicaraguan poet, priest and political revolutionary who wielded his pen as a weapon against two autocratic regimes — the Somoza family dynasty and the left-wing Sandinista party that took its place — died March 1 in Managua, Nicaragua’s capital. He was 95.

His personal assistant, Luz Marina Acosta, confirmed the death to the Associated Press. Father Cardenal had recently been hospitalized for respiratory problems. In a sign of his renown in Nicaragua, the government of Sandinista leader Daniel Ortega ordered three days of national mourning, despite having persecuted Father Cardenal after he resigned from the Sandinista National Liberation Front (FSLN) in the early 1990s.

For many Nicaraguans, Father Cardenal was revered as a literary beacon and a moral authority, a Catholic priest who drew on Marx as well as the Gospels to champion social justice in his ministry and writings.

One of Latin America’s most acclaimed poets, he wrote verses that offered a cosmic fusion of spirituality, politics, science and history, while appearing at frequent lectures and readings that made him a kind of international ambassador for Nicaragua.

Father Cardenal drew few boundaries between his callings. The son of a wealthy Nicaraguan family, he fought with a revolutionary group in his late 20s, then emerged as a leading proponent of liberation theology, which emphasizes Jesus’s message to the poor and oppressed.

With a thick beard and trademark black beret, he offered Mass to Sandinista revolutionaries in the jungle, later joining Ortega when those forces marched into Managua in 1979 and toppled the Somoza family, whose rule had lasted more than 40 years.

Declaring that “the triumph of the revolution is the triumph of poetry,” he went on to work for nearly a decade as Nicaragua’s minister of culture, angering the Vatican with his mix of politics and religion while aiming to teach tens of thousands of Nicaraguans how to read and write.

Father Cardenal traced his religious convictions to the years he spent at a Trappist monastery in Kentucky, where he befriended Thomas Merton, the distinguished writer and priest. He later completed his religious training in Mexico, Colombia and Nicaragua, where he was ordained in 1965 and settled on the Solentiname Islands in Lake Nicaragua.

He had originally intended to establish a parish church. But Father Cardenal, a sculptor as well as a writer, instead presided over a sprawling art colony, turning Solentiname into a haven for painters and spiritual seekers alike. On Sundays, he led the islanders in discussions of Christianity, eventually recording their conversations and adapting the dialogues into a multivolume work, “The Gospel in Solentiname” (1975), considered a touchstone of liberation theology.

“As the peasants of Solentiname got deeper and deeper into the Gospel,” Father Cardenal wrote in the book, “they could not help but feel united to their brother and sister peasants who were suffering persecution and terror. . . . For this solidarity to be real they had to lay security, and life, on the line.”

Some of the islanders joined the Sandinistas, organizing in a 1977 raid against Anastasio Somoza Debayle’s forces with the blessing of Father Cardenal. The government responded by destroying the Solentiname chapel and other buildings, and Father Cardenal was labeled the “No. 1 enemy of the people.”

He later served in the Sandinista cabinet alongside his brother, education minister and fellow Catholic priest Fernando Cardenal, who died in 2016. Both men defied Pope John Paul II’s order to quit their government jobs and focus on their ministries, and during a 1983 visit to Managua the pope publicly reprimanded Father Cardenal, reportedly telling him to “straighten out your position with the church.”

The next year, Father Cardenal was suspended from the priesthood, setting off a break with the church that was repaired only last year, when he was absolved by Pope Francis. By then, Father Cardenal had become an outspoken critic of Ortega, whose party had stifled a rebellion from a CIA-backed army known as the contras and was accused of rampant corruption and human rights abuses.

His split from the Sandinistas was “perhaps his most important political legacy,” said Manuel Orozco, a Nicaragua scholar with the Inter-American Dialogue in Washington. The party had “refused to recognize the atrocities committed in the 1980s,” Orozco said in an email, and transformed “into a typical Latin American clientelistic and populist party.” After Ortega returned to power in 2007, he added, Father Cardenal “was politically persecuted by the government, publicly attacked by the regime and even legally prosecuted on false charges.”

“It was a beautiful revolution. But what happened is that it was betrayed,” Father Cardenal told the Agence France-Presse in 2015, recalling his turn away from the Sandinistas. “There is now the family dictatorship of Daniel Ortega. That’s not what we fought for.”

Ernesto Cardenal Martínez was born in Granada, on the shores of Lake Nicaragua, on Jan. 20, 1925. After graduating from a Jesuit high school, he studied literature at the National Autonomous University of Mexico and at Columbia University in Manhattan, where he immersed himself in American poetry.

“From Ezra Pound, William Carlos Williams and Marianne Moore he borrowed the belief that poetry is a public language of precise documentary facts that he called ‘exteriorismo,’ ” said Northwestern professor Harris Feinsod, author of “The Poetry of the Americas: From Good Neighbors to Countercultures.”

“At the same time, from Latin American poets like Rubén Darío and Pablo Neruda, he took the belief that poetry could be a vehicle for Latin American nations to craft independent political visions,” Feinsod added by email. Poems such as “Zero Hour” and “With Walker in Nicaragua” recalled the history of U.S. imperialism through figures such as Sam Zemurray, the head of United Fruit Company, and William Walker, who conquered Nicaragua in the mid-1850s.

Father Cardenal also spoke out against the Somoza regime in his verse, skirting government censorship by publishing outside the country as an “Anonymous Nicaraguan.” His later works increasingly incorporated scientific themes, notably in “Cosmic Canticle” (1989), a 500-page poem that drew on the theories of physicists such as Richard Feynman and Stephen Hawking.

“Science brings me close to God because it describes the universe and creation, and that brings me close to the creator,” he told the New York Times in 2015. “For me this is a prayer.”

Father Cardenal leaves no immediate survivors, according to local news reports. In recent years he led a Granada cultural center, the Casa de los Tres Mundos, and received literary honors including Chile’s Pablo Neruda Ibero-American Poetry Award and Spain’s Reina Sofia poetry prize.

In interviews, Father Cardenal declared that Jesus had led him to Marx, once calling himself “a revolutionary for the sake of His kingdom.”

“The Bible is full of revolutions,” he said at a public reading in 2014. “The prophets are people with a message of revolution. Jesus of Nazareth takes the revolutionary message of the prophets. And we also will continue trying to change the world and make revolution. Those revolutions failed, but others will come.”