Nearly 200 firefighters beat back a 4-alarm blaze in an Upper West Side apartment building Friday night.

Flames broke out on the fifth floor of the building on Amsterdam Ave. near 85th St. around 5:56 p.m.

Authorities said it spread another two flights down as well.

"These two buildings, they're old war tenements," said FDNY Chief James Leonard. "The fire started in 509 — we think on the third floor — then got into a shaft, which is common in these types of buildings."

One civilian and four firefighters were hurt. They are all expected to be OK.

There is no word yet on what might have caused the fire.