CAIRO, Egypt (AP) — Pope Shenouda III, the patriarch of the Coptic Orthodox Church who led Egypt’s Christian minority for 40 years during a time of increasing tensions with Muslims, died Saturday. He was 88.

The state news agency MENA said Shenouda died Saturday after battling liver and lung problems for several years, and a doctor who treated him several years ago said he suffered from prostate cancer that had spread to his lungs. He died at his residence in the main Coptic Cathedral in Cairo, several figures close to the pope said.

Tens of thousands of Christians packed into cathedral to mourn Saturday evening. Women in black wept and screamed. Some, unable to get into the overcrowded building, massed outside, raising their hands in prayer. “The Coptic Church prays to God that he rest in peace between the arms of saints,” a scroll read on a Coptic TV station, CTV, under a picture of the patriarch.

“Baba Shenouda,” as he was known to his followers, headed one of the most ancient churches in the world, tracing its founding to St. Mark, who is said to have brought Christianity to Egypt in the 1st Century.

For Egypt’s estimated 10 million Coptic Christians, he was a charismatic leader, known for his sense of humor — his smiling portrait was hung in many Coptic homes and shops — and a deeply conservative religious thinker who resisted calls by liberals for reform.

Above all, many Copts saw him as the guardian of their community living amid a Muslim majority in this country of more than 80 million people.

Shenouda sought to do so by striking a conservative balance. During the rule of President Hosni Mubarak, he gave strong support to his government, while avoiding pressing Coptic demands too vocally in public to prevent a backlash from Muslim conservatives. In return, Mubarak’s regime allowed the Church wide powers among the Christian community.

A sector of Christians — particularly liberals and youth who supported the revolution against Mubarak — grew critical of Shenouda, saying his conservative approach had brought little success in stemming violence and discrimination. Moreover, they argued, the Church’s domination over Christians’ life further ghettoized them, making them a sect first, Egyptian citizens second.

Christians have long complained of being treated as second-class citizens, saying they face discrimination in employment and that police generally fail to prosecute those behind anti-Christian attacks.

After Mubarak’s fall a year ago, Christians grew increasingly worried over the rising power of Muslim conservatives. Several churches were attacked by mobs, fueled in part by increasingly bold hard-line Islamic clerics who accused Christians of seeking to convert Muslim women or even take over the country. Christian anger was further stoked when troops harshly put down a Christian protest in Cairo, killing 27 people.

In an unprecedented move aimed at showing unity, leaders from the Muslim Brotherhood along with top generals from the ruling military joined Shenouda for services for Orthodox Christmas in January at the Cairo cathedral.

“For the first time in the history of the cathedral, it is packed with all types of Islamist leaders in Egypt,” Shenouda told the gathering. “They all agree ... on the stability of this country and on loving it, working for it and working with the Copts as one hand for Egypt’s sake.”

The Brotherhood’s political party in a statement Saturday offered its condolences “to the Egyptian people and its Christian brothers.”

Parliament speaker Saad el-Katatny, a Brotherhood member, praised the pope in an evening session, calling him a “man respected among Coptic Christians and Muslims“for his love of Egypt and his opposition to Israel’s annexation of Jerusalem. Under a long-standing order, Shenouda barred his followers from pilgrimage to Jerusalem as a protest of Israel’s hold on the city.

Yousef Sidhom, editor of the privately owned Coptic newspaper Al-Watani newspaper, defended Shenouda’s approach in dealing with his community’s problems. “He used peaceful means and patience as the weapons of the church,” he said. “In the coming period we need to continue arming ourselves with these tools.”

However, another prominent Christian columnist, Karima Kamal, argued that the policies only further put Christians in a sectarian category.

“This was the mistake of Baba Shenouda and his predecessor. The state wanted to deal with Christians through one person. We want the state to deal with Christians as citizens and for the Church to step aside,” she said.

“I understand why this happened. The state forced the Church to play that role and the Christians had no other way except to go through the Church,” she said. “Christians are increasingly dealt with just as a sect.”

In an usually assertive political move, the Church discretely urged followers to back a liberal, secular-minded political bloc in the first post-Mubarak parliamentary elections late last year, hoping to balance religious parties. Nevertheless, the Muslim Brotherhood won nearly half the seats in parliament and now dominate the political scene. More radical Islamic Salafis won another fifth of the seats, deepening Christian worries.

Under Church law, the process of choosing Shenouda’s successor can take up to three months, though an interim leader will be picked within a week. A synod of archbishops, bishops and lay leaders will then form a committee to come up with three candidates. The names are then put in a box and a blindfolded acolyte picks one — a step meant to be guided by the will of God.

Two leading contenders are close associates of Shenouda. Archbishop Bishoy, head of the Holy Congregation, the main clerical leadership body, is seen as the more conservative figure; Archbishop Johannes, the pope’s secretary, is younger — in his 50s — and seen as having a wider appeal among youth.

Shenouda was born Nazeer Gayed on Aug. 3, 1923, in the southern city of Assiut. After entering the priesthood, he became an activist in the Sunday School movement, which was launched to revive Christian religious education.

At the age of 31, Gayed became a monk, taking the name Antonious El-Syriani and spending six years in the monastery of St. Anthony. After the death of Pope Cyrilos VI, he was elected to the papacy in 1971 and took the name Shenouda.

He had one significant clash with the government, in 1981 when he accused then-President Anwar Sadat of failing to rein in Islamic militants. Sadat said Shenouda was fomenting sectarianism and sent him into internal exile in the desert monastery of Wadi Natrun, north of Cairo. Sadat was assassinated later that year by militants. Mubarak ended Shenouda’s exile in 1985.

The incident illustrated the bind of Egypt’s Christians. When they press too hard for more influence, some Muslims accuse them of causing sectarian splits. Many Copts saw Mubarak as their best protection against Islamic fundamentalists — but at the same time, his government often made concessions to conservative Muslims.

During the 1990s, Islamic militants launched a campaign of violence, centered in southern Egypt, targeting foreign tourists, police and Christians until they were put down by a heavy crackdown.

In the past decade, Muslim-Christian violence has flared repeatedly, mainly in towns of the south and in the Mediterranean coastal city of Alexandria. Sometimes it was sparked by local disputes that took a sectarian tone, sometimes by disputes over the building of churches. The most startling attack came on New Year’s 2011, when suicide bombers attacked an Alexandria church, killing 21 worshippers.

At the same time, Christian emigration has increased tremendously. Coptic immigrants in the United States, Canada, and Australia number an estimated 1.5 million, according to the pope’s official Web site.

Throughout, Shenouda largely worked to contain anger among Copts.

But in one 2004 incident, he stepped aside to allow Coptic protests, sparked when Wafa Constantine, the wife of a priest, fled her home to convert to Islam. Many Christians accused police of encouraging or forcing Christians to convert. Amid the protests, Shenouda isolated himself at the Saint Bishoy monastery until the government ensured Constantine returned home. She was later quoted as saying she converted to Islam to divorce her husband, since divorce is banned by the Church.

Shenouda kept a strict line on church doctrine — including the ban on divorce, except in cases of adultery — in the face of calls by secular and liberal Copts for reform, including reducing the role of clergymen in Christians’ life.

In recent years, the ailing Shenouda traveled repeatedly to the United States for treatment. Yasser Ghobrial, a physician who treated Shenouda at a Cairo hospital in 2007, said he suffered from prostate cancer that spread to his colon and lungs.

Throughout his papacy, Shenouda insisted on the Copts’ place in Egypt, where they lived before the advent of Islam.

“Egypt is not a country we live in but a country that lives within us,” he often said.