The incident occurred sometime between 9:30 p.m. and 10:30 p.m. on Haight Street somewhere between Masonic Avenue and Stanyan Street, according to police.
The 37-year-old victim told his roommate that five people surrounded him and hit him in the head multiple times with a metal object, police said.
The victim was taken to a hospital with life-threatening injuries. No arrests have been made in the case.
Anyone with information about the attack is encouraged to call the Police Department's anonymous tip line at (415) 575-4444 or send a tip by text message to TIP411.