The blaze was reported shortly before 9 a.m. on USS Bonhomme Richard, said Mike Raney, a spokesman for Naval Surface Force, US Pacific Fleet.
Seventeen sailors and four civilians were hospitalized with "non-life threatening injuries," Raney said in a brief statement. He didn't provide additional details.
Previously, officials said at least one person was treated for smoke inhalation, and they later said 21 were injured.
As of Monday morning, only five sailors remained in the hospital.
The cause of the fire was under investigation, but officials believe the fire started somewhere in the lower cargo hold of the ship.
The flames on the 840-foot amphibious assault vessel 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, Raney said - far fewer than the thousand typically on the ship when it's on active duty.
All crew members were accounted for, said Admiral Mike Gilday, Chief of Naval Operations.
"We are grateful for the quick and immediate response of local, base, and shipboard firefighters aboard USS Bonhomme Richard," Gilday said in a statement.
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, Raney said.