Two FDNY lieutenants saved four people trapped inside a fiery apartment building in Rockaway Beach on Monday morning, fire officials said.

Lts. Joseph Costa and Sean Hayden had arrived at the two-alarm fire at 173 Beach 91st St. around 2:30 a.m. to find a panicked woman straddling the third-floor window with her baby in her arms, the firefighters recalled.

“She was looking to drop the baby down to somebody,” said Costa, a Ladder 137 lieutenant who has been with the FDNY for almost 12 years. “From the front of the building, we heard her screaming. I just ran into the building.”

The panicked woman sat on the window as a pregnant woman stood behind her, holding a second child, inside the apartment. Both children were under the age of 2, the lieutenants said.

She was saying ‘it was burning up, and she was gonna throw her baby,” said Hayden, a Ladder 121 fire fighter and 14-year veteran.

The Bravest ran into the building and carried the two babies down and walked with the two women.

Five firemen and three police officers were among 15 people who suffered non-life-threatening injuries from the fire.

One man man jumped from the building before to the FDNY’s arrival at the scene. He sustained injuries to both legs and was taken to an area hospital, fire sources said.

The blaze was caused by an unattended candle on the second floor. It spread down to the ground level and had begun to travel to the third story as firefighters arrived, the sources added.

“If we had been a minute later, I think the situation would have been a lot different,” Hayden said.