Miles Scott, five, participated in events across the city including fighting mock crimes and receiving an honour from the mayor.
Make-A-Wish Foundation, which organised the event, received pledges from more than 10,000 people to lend a hand.
Miles, in treatment for several years, is now said to be in remission.
According to local television, the youngster thought he was just on his way to get a Batman costume so he could dress like his favourite superhero.
Miles nabs villains
But then he heard a broadcast from San Francisco Police Chief Greg Suhr appealing for help from “Batkid”.
This wish has meant closure for our family and an end to over three years of putting toxic drugs in our son’s body”
Natalie Miles’ mother
Next, the pint-sized superhero saved a “damsel in distress”, tied to cable car tracks along a major urban street.
A San Francisco Chronicle live blog of the day’s events showed hundreds of people cheering Miles on during the “rescue”.
Miles was ferried from events in one of two “Batmobiles“, or black Lamborghinis with Batman removable stickers, which were escorted by police.
Later, he foiled a faux robbery in the city’s financial district with the help of an adult Batman impersonator.
Authorities who participated in the day’s events pretended to apprehend the villain, the Riddler.
Miles also travelled to AT&T Park to rescue the San Francisco Giants baseball team mascot by disarming a fake bomb planted by another classic Batman baddie, the Penguin.
The US justice department even prepared an indictment for the Riddler and the Penguin.
Towards the end of the day San Francisco Mayor Ed Lee gave Miles a key to the city.
An estimated 7,000 people turned up to help make Miles’ wish come true.
The Make-A-Wish Foundation said the event was “on the scale of a military operation”.
In real life, Miles has defeated an enemy even more ruthless than Batman’s nemeses – he is presently recovering from leukaemia, with which he was diagnosed at 18 months old.
His mother, Natalie, said Friday was a “celebration” of her son’s completion of treatment in June.
“This wish has meant closure for our family and an end to over three years of putting toxic drugs in our son’s body,” she wrote in a statement on the foundation’s website.
His father, Nick Scott, thanked the charity and everyone else who took part.
“All the doctors, nurses and all the other parents that have to deal with the same thing we’re going through, I hope they get a conclusion to their illnesses like we’re getting,” he told KGO-TV.