Twenty-four people, including four New York City firefighters, were injured Thursday evening when a four-alarm fire broke out in an apartment building on the city's Upper West Side.

In a Twitter post, the FDNY said that six civilians had suffered "serious" injuries. Eighteen others, including the four firefighters, suffered minor injuries.

Among the injured was a 7-year-old girl who was in cardiac arrest on the 21st floor, according to FDNY Chief of Department James Leonard.

He said she is now in good condition after firefighters carried her out of the building and revived her.

The inferno started in a third-floor apartment in the 33-story building on West 59th Street near 10th Avenue at around 5 p.m. Witnesses reported seeing flames shooting out of the building's windows as the fire spread to the fourth floor.

It wasn't clear what started the fire, but Leonard said open windows and high winds caused "very heavy smoke" to go into the hallways and rise up into the building's upper floors.

"Firefighters had a tough time getting across the hallway because of the wind," he said.

Nine people escaped to the roof to wait out the fire and were safely removed, said Leonard.

One resident, Shruti Kulkarni, tweeted that the fire had forced her to stay inside her apartment on the 7th floor.

Later, Kulkarni tweeted that she was able to get out of the building and was safe.

Firefighters went floor to floor to check on the residents, who include medical residents and doctors affiliated with Mount Sinai St. Luke's Roosevelt Hospital.

More than two hours after the fire began, the FDNY tweeted that the blaze had been "knocked down."

A woman who lived in the apartment where the fire started was able to get out of the building safely, her next door neighbor told the New York Post.

"She was completely covered with black ashes," the neighbor said. "I tried to have her go to the emergency room, but she was concerned about the damage in her apartment.

The Associated Press contributed to this report.