The 4-year-old boy in critical condition was unconscious and not breathing when he was taken from the water, said Fire Department Assistant Chief Bob Postel.
PHOTOS: Dozens rescued after boat capsizes off San Francisco
A good Samaritan performed CPR on him until a police officer took over, said San Francisco Police Officer Giselle Talkoff.
Photographs posted on social media showed youths and adults barefoot and wrapped in thick gray blankets on shore after being rescued. The boat, which was carrying 30 people, became fully submerged in the water.
Fisherman David Griffiths told the San Francisco Chronicle he tossed life jackets to the people in the water. He was taking off his shoes and getting ready to jump in when the first rescue teams arrived, Griffiths said.
Postel said rescue teams from the fire and police departments and the U.S. Coast Guard all rushed to the scene.
"There were lots of rescue boats on the water because of Fleet Week, so we were fortunate," he said. "We were able to get everybody out and accounted for quickly."
Griffiths said it was jarring to see the boat upend during what had been an otherwise beautiful day on the water.
"Seeing the bottom of it, that's not a normal thing," he said.
Authorities are investigating the cause of the accident.
PIER 45 BOAT CAPSIZED WITH ABOUT 30 JUV ON BOAT SOME ARE TRAPPED UNDER THE HULL. USCG BOAT/HELIO/DIVERS EN ROUTE. pic.twitter.com/KnEKFVgpjx— San Francisco Fire (@sffdpio) October 8, 2016