The San Diego Fire-Rescue Department reported an explosion in conjunction with the blaze, which struck at about 8.30am Sunday local time aboard the USS Bonhomme Richard, an amphibious assault vessel.
Aerial video footage from the scene showed much of the 257m warship engulfed in thick smoke, as firefighting boats in the harbour aimed streams of water at the burning vessel.
"18 Sailors have been transferred to a local hospital with non-life threatening injuries," Naval Surface Forces wrote on Twitter on Sunday afternoon, adding "The entire crew is off the ship and all are accounted."
About 160 sailors were aboard when the fire was first reported. San Diego television station KGTV, an ABC News affiliate, reported the ship was undergoing routine maintenance at the time and normally carries a crew of roughly 1000.
Rear Admiral Charles Brown, a US Navy spokesman, said the injured sailors had mostly sustained smoke inhalation and minor burns.
Around noon local time, the San Diego fire department said all its personnel had been directed to exit the pier, while aerial footage showed the blaze appearing to grow in size.
Two other warships docked nearby were moved to piers farther from the burning vessel within the next 90 minutes, the Navy said in a statement, putting the number of people sent to the hospital at 17 sailors and four civilians.
The Bonhomme Richard, commissioned in 1998, has participated in several military operations over the years and also has appeared in a pair of Hollywood films - the 2012 sci-fi action movie Battleship, starring Liam Neeson and singer Rihanna, and Act of Valor, which featured active-duty US Navy SEALs, according to WGTV.
The ship was named in honor of Benjamin Franklin, one of America's founding fathers and author of the influential Poor Richard's Almanack, which he wrote under the pseudonym Poor Richard or Richard Saunders.