Cardinal Edward Egan, the archbishop emeritus of New York who was popular in Rome but had a rocky tenure as head of the nation’s second largest archdiocese, died Thursday afternoon of cardiac arrest. He was 82.

His successor, Cardinal Timothy Dolan, said Egan was stricken at his residence at the Chapel of the Sacred Hearts of Jesus and Mary and rushed to NYU Langone Medical Center, where he was pronounced dead at 2:20 p.m. Thursday.

“Thank God he had a peaceful death, passing away right after lunch today, with the prayers and sacraments of his loyal priest secretary, Father Douglas Crawford,” Dolan said in a blog post.

Egan was appointed archbishop of New York in May 2000, a post he held for nine years.

In some ways, Egan’s chances for success in New York were slim.

He took over from one of the American Church’s most colorful figures, Cardinal John O’Connor, whose gregarious nature stood in stark contrast to Egan’s, and whose disdain for management left Egan with an archdiocese with severe financial challenges.

His tenure as archbishop of New York was marked by public battles with priests, questions about how he handled allegations of clergy sexual abuse, and criticism of his general demeanor.

Priests and lay Catholics in the archdiocese bristled at his decisions to close schools and merge parishes, and he was viewed by some as distant and authoritarian.

For example, an anonymous letter criticizing the cardinal’s leadership style purportedly written by a group of New York priests was circulated in 2006.

Egan also took heat for leaving New York just weeks after the 9/11 attacks for Rome, where he was leading a worldwide meeting of bishops. Many Catholics said New Yorkers needed a moral leader at that time, and that Egan let that role fall to others while he focused on his Vatican duties. Egan maintained that Pope John Paul II declined his request to leave the meeting early, though he eventually did return to New York just days before it was scheduled to end. (The man who took his place chairing the proceedings: the then little-known Archbishop of Buenos Aires, Jorge Mario Bergoglio, who went on to become Pope Francis in 2013.)

But under Egan’s leadership, the archdiocese made gains in getting its financial house in order: the local Catholic Charities budget doubled, and Catholic agencies became debt free.

He was a popular figure in Rome. Fluent in five languages, Egan was one of only six canon law experts tapped to work with Pope St. John Paul II in revising the Church’s constitution in the 1980s.

When he was made a cardinal in 2001, Egan’s massive delegation — 850 strong — could not fit into a single hotel ballroom, so multiple parties were thrown in his honor instead. So many, that he was unable to attend them all.

Egan, a strong defender of Catholic orthodoxy, won praise from conservative Catholics for his clashes with Catholic politicians who support abortion rights.

Egan rebuked former Mayor Rudolph Giuliani for taking Communion at a public Mass during Pope Benedict XVI’s 2008 visit to New York.

Toward the end of his reign, the orthodox prelate — who routinely spoke out against abortion, homosexuality, and contraception — surprised some Catholics by suggesting the Church should reexamine its practice of requiring celibacy for its priests.

Egan was born in 1932 in Oak Park, Ill., and after studying for several years in Rome, he was ordained a priest in the archdiocese of Chicago in 1957. He worked first in Chicago archdiocese, rising to co-chancellor, before returning to Rome in 1971 to work in the Roman Curia.

He was ordained a bishop in 1985, and moved to New York where he was in charge of Catholic education. He was named bishop of Bridgeport, Conn., in 1988, the post he held until he returned to New York as its ninth archbishop.

The Archdiocese of New York has not announced funeral plans yet.