Chicago's Cardinal John P. Cody, 74, who had been the embattled head of the nation's largest Roman Catholic archdiocese since 1965, died of cardiac arrest early Sunday at Northwestern Hospital in Chicago.

A hospital spokesman said emergency personnel were summoned to Cardinal Cody's residence Saturday night after a private duty nurse discovered the cardinal "in some difficulty," and had administered cardio-pulmonary resuscitation. He was pronounced dead at the hospital at 12:19 a.m. Sunday. The cardinal had been in failing health for some time, with heart ailments and diabetes.

During a church career that spanned more than half a century, Cardinal Cody gained a reputation as tough administrator who was the master builder of countless schools and seminaries. As leader of the church in Chicago, he was the spiritual leader of 2.4 million Roman Catholics, led 2,700 priests and 6,400 nuns, was controller of the nation's largest private school system, and held nearly total control of the archdiocese corporation's $184 million.

He had served as treasurer of both the National Conference of Catholic Bishops and the United States Catholic Conference.

His reputation as a forceful but competent administrator suffered a blow in September 1981 when The Chicago Sun-Times newspaper began printing a series of front page stories reporting that federal prosecutors were conducting an investigation to determine whether Cardinal Cody had improperly diverted as much as $1 million in church funds to a lifelong friend, Helen Dolan Wilson, of St. Louis. The government confirmed that an investigation was in progress.

The cardinal denied any wrongdoing, saying the allegations were a "vicious joke" and that "any accusations against the shepherd are also against the church." The investigation, as well as the news coverage of it and personalites surrounding it, would divide the city of Chicago, its people, press, and pulpits, until the cardinal's death.

The Chicago archdiocese released a statement yesterday that it said the cardinal wrote in January during a hospital stay, in which the cardinal said he had "forgiven my enemies." But, the cardinal added in the statement,"God will not so forgive."

Cardinal Cody said that while he could not change the hearts or wills of those who "seemingly acted out malicious designs against me," he could "forget the personal hurts, the untimely deaths of those close and the scandal to the flock," and could "turn aside from the personal abuse, the plotting, the media maneuvering and even the incomplete untruths."

However, he said, "God's is another way. He stands before my former enemies insisting forever with good will that they change. If they change it will be because God has given something to them that they do not now have -- a gift, a grace, to renew themselves by turning from a delusion toward truth."

In another development, it also was disclosed yesterday that a $100,000 insurance policy paid for by the cardinal will leave about $43,000 to Wilson, who borrowed $57,000 against it in 1980. Her lawyer said the cardinal paid the premiums but that she owned the policy.

Cardinal Cody was no stranger to struggles. As bishop and then archbishop of New Orleans in the 1960s, he firmly enforced the racial desegregation of Catholic schools, often in opposition to Catholic parents. While serving as coadjutor bishop of New Orleans in 1961, he braved pickets and threats to escort black children to school during periods of high tension.

"All these people have the same rights that any of us have as citizens," he said, "and they have every right we have as Christians -- certainly primary among these rights is the right to an education."

Pope Paul VI named him archbishop of Chicago to succeed Cardinal Albert Meyer. A year later, as Chicago readied itself for a series of civil rights marches, Cardinal Cody had a letter read in all Catholic churches saying, "A crusade for freedom and equality is under way and you and I as Catholics and Americans must be part of it." He was named a cardinal in 1967.

He came under fire in recent years for what some regarded as an aloof and autocratic leadership style, with little regard for Vatican II's rules of collegiality. He also came under fire for closing five inner city schools without consulting the school board. But he also started a program where wealthy churches made direct contributions to inner city churches

While he was attacked for forcing aging parish preiests into retirement, he also established a pension plan for them. He responded to challenges to his authority by pointing out that "I have the job and I'm responsible for it, nobody else."

Cardinal Cody was born in St. Louis. In his youth he hung around fire stations, where his father worked, was a "ham" radio operator, and played soccer. He entered a St. Louis preparator seminary at the age of 12, and then attended the North American College in Rome, where he spent 13 years and earned doctoral degrees in philosophy and theology.

He was ordained in 1931, became an auxiliary bishop of the St. Louis Archdiocese in 1947, bishop of Kansas City-St. Joseph in the mid-1950s, then went to New Orleans where he rose to archbishop.