Navy officials announced Thursday that the fire on the USS Bonhomme Richard docked at Naval Base San Diego has been extinguished, and investigators will now examine the 840-foot amphibious assault ship to see if it is salvageable.

The fire broke out Sunday in the ship’s lower armored vehicle storage area and quickly spread throughout the vessel. The flames lasted for four days as Navy officials and federal firefighters worked through the night to extinguish the fire, which at one point reached up to 1,000 degrees Fahrenheit.

The vessel shifted Wednesday night and listed toward the pier, prompting the Navy to briefly pull off firefighting sailors searching in the bowels of the U.S. warship for remaining hot spots, Navy officials said. The sailors were back on the ship within an hour.

A helicopter from Helicopter Sea Combat Squadron (HSC) 3 combats a fire aboard the amphibious assault ship USS Bonhomme Richard (LHD 6) at Naval Base San Diego, Tuesday, July 14, 2020. 

A helicopter from Helicopter Sea Combat Squadron (HSC) 3 combats a fire aboard the amphibious assault ship USS Bonhomme Richard (LHD 6) at Naval Base San Diego, Tuesday, July 14, 2020.  (U.S. Navy via AP)

Helicopters dumped more than 1,500 buckets of water on the ship, which had been docked in San Diego harbor undergoing maintenance.

The Navy believes a spark from an unknown source first ignited heavy-duty cardboard boxes, rags and other maintenance supplies that were being stored in the lower vehicle storage area. But the precise cause of the fire remains unclear.

Rear Adm. Philip Sobeck, the commander of the strike group whose flagship is the USS Bonhomme Richard, said the Navy’s fire teams are investigating every space of the ship to verify the absence of fire.

“We did not know the origin of the fire. We do not know the extent of the damage,” he said. “It is too early to make any predictions or promises of what the future of the ship will be. We cannot make any conclusions, until the investigation is complete.”

Experts said shipboard fires are difficult to douse.

"It's very difficult to choke off oxygen in open deck spaces" and then to follow the flames into all the nooks on a craft, said maritime lawyer Rod Sullivan, who served in the Navy.

NAVY UPDATES CORONAVIRUS POLICY TO ALLOW CHURCH ATTENDANCE, ‘MAJOR VICTORY’ FOR RELIGIOUS LIBERTY ADVOCATES

It's not uncommon for ship fires to take days to extinguish, he added, pointing to a fire last month on a car-carrying cargo ship that burned for eight days in Jacksonville, Fla.

The difficulty was compounded aboard the USS Bonhomme Richard because it was undergoing maintenance and there was scaffolding, along with other equipment and debris in the way of firefighters.

Sobeck has said he is hopeful the ship can still be repaired but no one will know until it is safe enough for crews to access all areas.

It could cost an estimated $4 billion to replace the ship if it is deemed un-salvageable. The Bonhomme Richard was nearing the end of a two-year-long upgrade estimated to cost $250 million. It was being done so the ship could start being used to deploy the Marine Corps' F-35Bs in the Pacific.

CLICK HERE TO GET THE FOX NEWS APP

Forty sailors and nearly two dozen civilians have been treated for minor injuries, heat exhaustion and smoke inhalation. No Navy personnel were hospitalized.

The Associated Press contributed to this report.