A now-fatherless 4-year-old boy saluted the flag-draped coffin carrying an NYPD detective and airman killed by a Taliban suicide bomb as thousands outside St. Patrick’s Cathedral joined Wednesday to mourn.

Sitting on the shoulders of a uniformed police officer, Ryan Lemm paid his final respects to his father, Joseph G. Lemm, an Air National Guard technical sergeant who died in Afghanistan last week.

“Today we say farewell to a hero of our time and a hero for all ages,” said NYPD Commissioner William Bratton, one of several who delivered eulogies.

The Rev. Christopher Monturo, Lemm’s pastor at Saint Anthony of Padua Church in West Harrison, in Westchester County, gave the homily, calling the fallen officer a “Superman” and his death serving the nation a “final heroic act.”

Monturo, turning to Lemm’s widow, Christine, and the couple’s two children, said, “We want to help you dry your tears.”

Little Ryan — wearing a red necktie and dark suit, a police shield pinned to his lapel — played on a cop’s shoulders, doffing a police cap with his dad’s coffin a few feet away.

advertisement | advertise on newsday

The boy, startled, had put his hands over his ears when the voice of the NYPD ceremonial unit’s announcer told the officers over the loudspeaker to “present arms!” As pallbearers carried the casket down the cathedral steps, the boy joined the officers solemnly arrayed around them in a final salute. Lemm was buried at Gate of Heaven Cemetery in Hawthorne.

In a Mass overseen by the archbishop of New York, Cardinal Timothy Dolan, Lemm’s daughter, Brooke, 17, read from Ecclesiastes — passages speaking of “a time to be born and a time to die,” and “a time to kill and a time to heal.”

Lemm, 45, is one of six American service members who died Dec. 21 in the attack. An assailant on a motorcycle packed with explosives crashed into a patrol convoy near Bagram Air Field. The Taliban have claimed responsibility.

“Joe dedicated himself to the highest ideals of the city, this profession, this department, this nation. He dedicated himself to freedom,” Bratton said, as he promoting Lemm posthumously to first-grade detective, an elevation common after line-of-duty deaths. The move increases the benefits a family receives.

Officials recalled how Lemm, whose roots are in Nebraska and Iowa, enlisted in the Air Force in 1988, and fulfilled his dream to move to New York City by becoming an NYPD cop in 2000.

Get the Newsday Now newsletter!

The best of Newsday every day in your inbox.

“Our city is heartbroken. There are people mourning in every part of this great metropolis,” said Mayor Bill de Blasio, who attended with his wife, Chirlane McCray.

As police motorcycles roared past the church and a hearse pulled up to St. Patrick’s with Lemm’s coffin, pedestrians watched from cordoned-off streets in front of Fifth Avenue shops; office workers stared from windows overlooking the church to watch the rites.

Along with police officers from the New York area and as far away as Chicago who came to pay respects, there were airmen and airwomen in blue dress uniforms and members of all branches of the military.

Lemm, of West Harrison in Westchester County, was a member of the 105th Airlift Wing based in Newburgh. He had been deployed twice to Afghanistan and once to Iraq after joining the NYPD. One of his early police assignments was picking through the rubble of the World Trade Center’s Twin Towers to search for survivors.

Bratton noted that 1,110 reservists are in the NYPD’s ranks, including 130 on active duty.

advertisement | advertise on newsday

Lemm’s eulogizers paid tribute to the five others killed in the Dec. 21 attack, including the Long Island airman, Staff Sgt. Louis Bonacasa of Coram, whose funeral is Saturday at New Beginnings Christian Center in the hamlet.

Until his death, Lemm would attend line-of-duty funerals, said Monturo. “He never missed one.”

With Gary Dymski