US Navy says fire has been put out aboard USS Bonhomme Richard in San Diego

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, July 14. On the morning of July 12, a fire was called away aboard the ship while it was m

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.

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

Related: 57 injured following explosion, fire about ship at Naval Base San Diego

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.

P-NAVY-SHIP-FIRE-10_WTVT5026_146.mxf_.00_00_20_00.Still002.jpg

"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.

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.

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.

Read updates at FOXNews.com.