Two firefighters died while battling a raging fire that erupted Wednesday night inside a cargo ship carrying 5,000 cars at Port Newark in New Jersey, fire officials said.

The blaze broke out around 9:30 p.m., and responding firefighters found five to seven vehicles already burning when they reached the 10th floor. The flames quickly spread to the 11th and 12th floors, Newark Fire Chief Rufus Jackson said in a news conference early Thursday.

The firefighters "made an attempt to extinguish the fire and, because of the intense heat, they got pushed back out of the area where the initial fire was," Jackson said, adding that two of the firefighters were lost as the crew backed out of the structure.

Firefighters were initially unable to find their lost colleagues. When the lost firefighters were eventually found, they were removed from the ship and pronounced dead.

NEW JERSEY HELICOPTER CREW RESCUES FIREFIGHTERS WHOSE BOAT WENT OVER WATERFALL

firefighter boat spraying deck of cargo ship with water

Firefighters continued working to extinguish the fire into the early morning hours on Thursday at Port Newark in New Jersey. (WABC via AP)

"We lost two firefighters today," said Newark Mayor Ras Baraka at the scene. "A tragedy for us in the city of Newark and tragic for all firefighters who know what it means to go in a burning structure in a danger that you are going to have to experience when you do so."

BODYCAM CAPTURES WISCONSIN POLICE OFFICER RESCUING COWS FROM BARN FIRE

The names of the firefighters killed were not immediately released.

smoke rising from cargo ship

Firefighters responded to the blaze around 9:30 p.m. and the flames quickly spread to other floors inside the ship. (WABC via AP)

Firefighters continued battling the blaze into the morning hours on Thursday.

"Although this is a difficult fire, a different type of fire, they're still willing to put themselves on the line for others," Jackson said. "This is a unique service that we’re in. We love what we do. We love each other and we protect each other. It’s unfortunate when we have loss. This is a tragedy. This is something that I as a chief never want to face, but we have to be there, we have to be strong for the family at this point."

cars on deck of cargo ship with smoke

The cargo ship was carrying 5,000 automobiles when the fire erupted, officials said. (WABC via AP)

U.S. Coast Guard Northeast said it also responded to the vessel fire and that all the ship's crew were accounted for.

Marine traffic trackers show the Grande Costa D’Avorio, which was built in 2011, arrived from the Port of Baltimore several days earlier.

CLICK TO GET THE FOX NEWS APP

The cargo ship is an Italian-flagged vessel operating under the Grimaldi Group’s Grimaldi Deep Sea company.

The vessel’s crew was loading vehicles onto the massive cargo ship when the fire broke out, the company said in a statement obtained by WNBC.

The Associated Press contributed to this report.