The stabbing was reported around 1:15 a.m. near the intersection of 26th and Mission streets.
The 42-year-old victim was on the Muni bus when four suspects boarded the bus at 20th and Mission streets and began harassing him about whether he was affiliated with a gang, according to police.
The victim got off the bus at 26th and Mission streets and was followed by the suspects, who attacked him and stabbed him in the chest, police said.
The victim walked to nearby St. Luke's Hospital and was subsequently transported to San Francisco General Hospital to be treated for his injuries, which are not considered to be life-threatening, police said.
The suspects, men believed to be in their 20s, had not been found as of Tuesday morning, according to police.
Anyone with information about the stabbing is encouraged to call the Police Department's anonymous tip line at (415) 575-4444 or send a tip by text message to TIP411.