Twenty-one people have been injured after an explosion and fire on a ship at Naval Base San Diego.

The blaze was reported shortly before 9am local time on USS Bonhomme Richard, said Mike Raney, a spokesman for Naval Surface Force, US Pacific Fleet.

Seventeen sailors and four civilians were hospitalised with “non-life threatening injuries”, Mr Raney said.

Navy Ship Fire
The ship had been undergoing maintenance work (Denis Poroy/AP))

Previously officials said at least one person was treated for smoke inhalation.

The cause of the fire was under investigation. It was not immediately known where on the 840ft amphibious assault vessel the blast and the fire occurred.

The flames sent up a huge plume of dark smoke visible around San Diego.

San Diego is the Bonhomme Richard’s home port and it was undergoing routine maintenance at the time of the fire.

About 160 sailors and officers were on board, Mr Raney said, which is far fewer than the thousand typically on the ship when it is on active duty.

The ship has the capacity to deploy and land helicopters, smaller boats and amphibious vehicles.

Two other docked ships, USS Fitzgerald and USS Russell, were moved to berths away from the fire, Mr Raney said.