One of the cops trapped in a Brooklyn apartment building fire allegedly set by a bored teen has been declared brain dead, sources said.

Officer Dennis Guerra remains on life support at Montefiore Hospital in the Bronx, where he was transferred after doctors struggled to stabilize him at Coney Island Hospital and Jacobi Hospital.

Family members wept outside an intensive care unit in a hallway crawling with concerned cops and a police department chaplain.

Guerra, 38, a married father of four, and his partner, Rosa Rodriguez, 36, were the first two on the scene of a fire in a Coney Island apartment building, where they were immediately overcome by dense smoke as they stepped off an elevator into a 13th-floor hallway where a mattress had been set on fire.

Rodriguez was in critical condition at Cornell Medical Center’s burn unit in Manhattan, where she was placed in a hyperbaric chamber.

After the accused arsonist, Marcell Dockery, 16, told investigators he was “bored,” according to sources, he was caught on camera with a wide grin as he was walked from a Brooklyn precinct, a gesture that outraged cops and Guerra’s heartbroken family.

“We saw him smiling on TV, is this a joke? We are going through so much right now,”said Guerra’s mother, Miriam, outside her home before rushing off to the hospital as Guerra’s condition worsened.

“This is a very tough time for us. Because he was bored, two officers are now fighting for their lives, and one of them is my son,” she said.

Dockery — who set up an entire Facebook page devoted to his “obsession’’ with fire — was charged with felony arson and assault and reckless endangerment.

Mayor Bill de Blasio and Police Commissioner Bill Bratton visited Guerra’s family at the hospital.

“The tragedy here is that a 16-year-old young man would not have common sense enough to understand the implications of lighting a mattress, as has been alleged, on fire in his own building,” Bratton said before the hospital visit.

“How can any of us make any sense out of that?”

De Blasio saluted Guerra and Rodriguez for their bravery.

“We have such respect for what they have done for this city,” de Blasio said. “We feel for their families as they go through this terrible time, but we know that these two officers did what they did because people were in danger and they answered the call.”

Additional reporting by Elizabeth Hagen and Lorena Mongelli