Up to 30,000 people fled or were evacuated from 19 buildings in the city's financial district yesterday after a pipeline rupture sent natural gas fumes, oil mist and traces of a toxic chemical roaring into the air like a geyser.

At least five people were taken to hospitals after being overcome by gas fumes. Others complained of discomfort, dizziness and headaches.

Traces of polychlorinated biphenyls were detected in the residue from the leak. Tests were being made to determine the PCB level in the fine spray blanketing streets, buildings and cars. Dr. Richard Wade of the state Occupational Safety and Health Administration warned people heavily hit by the spray to get rid of their clothes and shoes.

Pacific Gas & Electric Co. tests showed the PCB was present in the oil at a level of 25 parts per million-- one half that considered harmful by the federal government.

PG&E spokesmen said there was no health hazard, but Wade said he would recommend the area be cleaned up before the evacuees are allowed back to work.

PCB, used as an industrial insulator, is suspected of causing cancer and birth defects.

PG&E said the flow of gas to the broken main at Sacramento and Battery streets was mostly shut off after it had leaked for more than an hour.

Thousands of people, many holding handkerchiefs over their noses, quickly evacuated the buildings, including three 45-story office towers, police said. Among those evacuated was Sen. S. I. Hayakawa (R-Calif.), 75, who said he got his "exercise for a week" when he was forced to walk down 22 flights of stairs at One Embarcadero Center.