A veteran New York City firefighter and Bethpage resident plunged off a roof and down five stories to his death Thursday afternoon while battling a minor blaze at a Queens apartment building, officials said.

William Tolley, 42, from Ladder 135, with 14 years on the job, fell as he worked a building fire in Ridgewood, said FDNY Commissioner Daniel Nigro with Mayor Bill de Blasio at his side, both visibly shaken as they held a news conference at Wyckoff Heights Medical Center in Bushwick, Brooklyn, where Tolley was pronounced dead.

Married and the father of an 8-year-old girl, Tolley fell as he worked on the roof of the building at 1615 Putnam Ave. — the bucket of a ladder close by, extending onto the structure.

The death of a seasoned FDNY firefighter — battling a blaze in one moment and in the next, careening to the sidewalk below, unsettled witnesses, caused unimaginable grief for his family, and stunned those he worked with at several firehouses in the city and on Long Island.

De Blasio, flanked by Nigro and other FDNY and city officials, broke the news of Tolley’s death to a city well-versed in the daily hazards of being a city firefighter but far from immune to them. Just last month the FDNY mourned the loss of EMT Yadira Arroyo, 44, who was struck and killed after her ambulance was stolen.

“I’m very sorry to report that tragedy has struck our city again,” de Blasio said at the late-afternoon news conference. “We lost another hero today.”

advertisement | advertise on newsday

Tolley had been perched on the ladder but it was unclear if he was in the bucket at the time he fell, about 20 minutes into battling the blaze, Nigro said. An investigation will check whether there was any mechanical failure on the ladder.

Tolley, who had also served in fire departments in Bethpage and Hicksville, leaves behind his wife, Marie, and daughter, Isabella, the mayor said.

“A man dedicated to protecting others gave his life for this city,” de Blasio said, adding that he had met with family at the hospital. “Today he made the ultimate sacrifice. . . . Everyone is in a state of shock, grief. To his family we say we will stand by you, not only today but in the days ahead, and for the years and years to come.

It was next left to Nigro to add Tolley’s name to the tally of FDNY firefighters killed in the line of duty. That grim number now stands at 1,147, Nigro said.

“Certainly, our hearts are primarily with William’s wife, Marie, his daughter, Isabella, his mom and dad, his brother and with the members of Ladder 135, Engine 286, who have lost a dear colleague, a dear brother. A terrible tragedy for the department,” Nigro said.

Tolley started working as a volunteer firefighter with the Bethpage Fire Department in 2011, assigned to Ladder Co. No. 3 after starting there as a junior firefighter, according to fire department officials in Bethpage. He had previously been a member and lieutenant in Hicksville Fire Department Rescue 8.

“He was a good guy,” said Hicksville Fire Chief Rich Diaz, adding that Tolley left the company about 10 years ago. “Anything you needed he was always there to help.”

Hicksville fire dispatcher Christopher Valero said Tolley was a drummer in a heavy metal band. He was good-natured, Valero said, with the gift of gab, and also “buffy” — parlance of the trade, the dispatcher added, to describe a firefighter gung-ho about taking on a blaze.

“Conversations with him would last three hours,” Valero said of Tolley. “Fun guy.”

Officials said his death had nothing to do with the relatively minor blaze he and about 100 other firefighters had come to help extinguish.

advertisement | advertise on newsday

The FDNY responded to the scene at 2:20 p.m. Thursday to douse a fire in a one-bedroom apartment on the second floor of the five-story brick building — one of several spanning a residential section of Putnam Avenue.

Tolley worked on the roof Thursday as the outside ventilation firefighter, Nigro said, an assignment that entails freeing hot gas and smoke churned up by a fire below so people above the flames can escape.

The fire was contained to one room and was under control “rather quickly,” by around 3 p.m., officials said.

“It was nothing about the fire that really had anything to do with the accident that occurred,” Nigro said. “It was really in the operation that he was performing on the roof, which is a routine operation for us, and somehow he fell from the roof.”

Other firefighters were on the roof at the time, and Nigro said Tolley was a senior firefighter in the unit.

advertisement | advertise on newsday

“I join with all FDNY members in honoring the memory of our brother who unfortunately lost his life in the line of duty earlier today,” Jake Lemonda, president of the FDNY-Uniformed Fire Officers Association, said in a statement. “This is an extremely dangerous job that our dedicated members put their lives on the line every day to protect the residents of the City of New York. On behalf of the officers union, I offer condolences to his family and friends.”

NYPD Commissioner James O’Neill expressed his condolences to the FDNY in a tweet.

“Thoughts & prayers from all #NYPD are with the men & women of @FDNY following line-of-duty firefighter death today in Queens. Rest in peace.”

The most recent FDNY firefighter to die in the line of duty was Battalion Chief Michael J. Fahy in September 2016. Fahy, 44, of Yonkers, was killed by falling debris from an explosion that blew the roof off a home in the Bronx.

Tolley died the same day Fahy’s name was added to the FDNY memorial wall.

Two neighbors, including one with an FDNY cap, lowered the U.S flag on the lawn of Tolley’s Bethpage home to half-staff Thursday. Another left a bouquet of flowers in front of the family’s door.

Late Thursday afternoon dozens of people gathered by the corner of Putnam and Wyckoff avenues in Ridgewood as several fire officials worked at the scene. A pair of ladders remained attached to the building.

Angie Cordero, 43, was in her house directly across the street from the building watching from the second-story window when she saw a firefighter fall that she would later learn was Tolley.

“I was just looking at what was happening. All of a sudden I heard a noise,” she said. “I just saw when the body came over. I started to scream . . . you see this in movies, not here. It didn’t feel real.”