The boy walked away from a middle school on Church Street yesterday morning.
Police were urgently trying to find him because of his age and a medical condition.
Wednesday morning, BART community service officers spotted him riding a train.
ABC7 was at the 16th Street BART station as the boy was reunited with his family.
They recently moved from San Francisco from the East Coast.
The San Francisco Police Department tweeted a photo of the child Tuesday night, saying he was last seen near 450 Church Street in San Francisco. He had last been seen in a dark hoodie and dark pants and was also carrying a backpack.