Det. Steven McDonald, the quadriplegic NYPD officer who inspired generations by forgiving the teenager who shot him and overcoming his disabilities to remain an active cop, died Tuesday at North Shore University Hospital, officials said. He was 59.

McDonald died at 1:10 p.m. after lingering on life support for four days after an apparent heart attack on Friday, a source said. Law enforcement sources said McDonald never regained consciousness and showed little brain activity in the days after his emergency hospitalization.

“New York City is heartbroken by the loss of NYPD Detective Steven McDonald, who for 30 years has been this city’s greatest example of heroism and grace,” according to a statement from New York City Mayor Bill de Blasio. “I will forever cherish my last conversation with Detective McDonald, late last year. His words encouraged all of us to continue to bring police and communities closer together.”

Officials said a full departmental funeral was being planned for 9:30 a.m. Friday at St. Patrick’s Cathedral in Manhattan. Cardinal Timothy Dolan, who was a close friend of McDonald, will officiate, said a spokesman for the archdiocese.

A public wake is planned for Wednesday and Thursday at the St. Agnes Parish Center adjacent to St. Agnes Cathedral at 29 Quealy Place in Rockville Centre. Visitation on both days is scheduled for 2 to 4 p.m. and 7 to 9 p.m.

The NYPD released a statement shortly after McDonald’s death. “It is with great sadness that Police Commissioner James P. O’Neill, and the men and women of the New York City Police Department, announce the death of Detective First Grade Steven McDonald, who passed away shortly after 1 p.m. today at North Shore University Hospital on Long Island while in the comforting presence of his wife, Patti Ann; his son, Conor, an NYPD sergeant; his friends and colleagues,” the statement said.

“No one could have predicted that Steven would touch so many people, in New York and around the world,” said O’Neill. “Like so many cops, Steven joined the NYPD to make a difference in people’s lives. And he accomplished that every day. He is a model for each of us as we go about our daily lives. He will be greatly missed, and will always remain a part of our family.”

McDonald was on patrol in Central Park in 1986 when a bullet fired by 15-year-old Shavod Jones left him a quadriplegic. After serving time in prison for attempted murder, Jones was released on parole in 1995 and died in a motorcycle accident just days later.

Despite his paralysis, which required that he use a respirator to breath and a wheelchair for mobility, McDonald remained an active member of the NYPD and regained his ability to talk.

He forgave Jones, and as a police officer was promoted to detective and the rank of lieutenant.

McDonald was known for giving inspirational talks at public and parochial schools about what it means to forgive.

McDonald’s wife, Patricia Ann, is the mayor of Malverne. His son, Conor, also a member of the NYPD, was promoted to sergeant last year.

“We are blessed that NYPD Detective Sergeant Conor McDonald continues in his father’s footsteps and will ensure his legacy lives on in the greatest police department in the world,” the mayor said.

Tributes to McDonald poured in.

“Steven McDonald was the most courageous and forgiving man I have ever known,” said PBA President Patrick J. Lynch. “Despite the tremendous pain in his life, both physical and emotional, his concern for his fellow police officers and for the people of New York City never wavered. Since that fateful day in 1986, Steven dedicated his life to fighting hate and encouraging forgiveness through his actions. He was a powerful force for all that is good and is an inspiration to all of us. His was a life well lived. We join his family — a true New York City police family — his friends and fellow officers in prayer and mourning the loss of a truly special man. He was a true American hero.”

Longtime Queens District Attorney Richard Brown said he was sad to learn of McDonald’s death, and called him a “true hero.”

“Steven was an inspiring human being and a man of deep and abiding faith who, when confronted by adversity early in his police career, responded with courage, grace and dignity. I was proud to call him my friend,” Brown said in a statement.

McDonald was an avid Rangers fan, and the team also mourned him, saying, “We are deeply saddened to learn of the passing of Detective Steven McDonald, a cherished member of the Rangers family. Steven exemplified the true meaning of the word hero and also personified the ‘Blueshirt Faithful.’ He is an inspiration to us all and his legacy will continue live on in our hearts and minds. Our thoughts and prayers are with Patti Ann and Conor and the entire McDonald family.”

Nassau District Attorney Madeline Singas praised his character. “NYPD Detective Steven McDonald famously forgave the teenage gunman who left him paralyzed from 30 years ago,” she said in a prepared statement. “In that time, he became a voice for peace and served as an inspiration for countless people. Detective McDonald was a true American hero and we should all aspire to live a life of service like him. I express my deepest condolences to Patti Ann, Conor and all of Detective McDonald’s family members and friends.”