For six weeks during the fall of 1918 and winter of 1919, San Francisco was a masked city. Everyone who lived in or visited town was required to cover his or her mouth and nose in public.

Those who did not were reprimanded, fined or arrested. The streets of the city looked like they were full of bank robbers, surgeons, attendees at a Venetian ball or Tokyo dwellers with colds.

The mask ordinance was San Francisco’s response to the most devastating outbreak of disease ever to hit the city before AIDS: the great influenza epidemic of 1918. In less than a year, 45,000 people fell ill and more than 3,000 died, out of a population of 500,000.

San Francisco was just a tiny part of one of the deadliest natural events in human history. The Spanish flu killed 50 million to 100 million people worldwide, including at least half a million Americans. While most flu epidemics kill young children and seniors, this strain mostly killed healthy young adults by causing a massive immune system overreaction.

The pandemic’s origins are unknown, but it may have started at a World War I troop-staging point in France near infected pigs that passed the virus to soldiers. The poor sanitation, face-to-face contact and stressed immune systems of wartime conditions facilitated the spread of the virus.

In the United States, the flu was first observed in Haskell County, Kan., in January 1918. Seven months later, a far more virulent strain appeared in Boston. It quickly spread across the country.

No more dances

The first San Francisco victim was Edward Wagner, a newly arrived Chicagoan who fell ill on Sept. 24. San Francisco’s chief health officer, Dr. William Hassler, placed him in a city hospital and quarantined his home.

But it was too late: By Oct. 9, the city was dealing with 169 cases of the flu. One week later, it was 2,000. The epidemic was on.

The city’s initial response was to urge people to avoid crowds and streetcars at rush hours. Streetcars were required to keep their windows open, hospitals were urged to take only the most urgent cases, and doctors and nurses were required to wear gauze masks.

When the disease continued to spread, the city took more drastic measures. After an Oct. 17 meeting attended by Hassler, Mayor James “Sunny Jim” Rolph, movie theater owners and representatives of the military, Rolph ordered all city schools and places of public amusement closed, banned lodge meetings, prohibited dances and recommended that churches hold services outside.

Bank clerks, barbers, hotel employees and druggists were required to wear masks, and all citizens were urged to do the same.

A week later, with the epidemic still raging, the Board of Supervisors went a step further, passing a measure requiring all San Franciscans to wear masks when they were with anyone, except when eating.

Several other American cities had advocated the use of masks, but San Francisco took the hardest line. Wearing a mask was promoted as a patriotic duty. The Red Cross ran an ad saying, “The man or woman or child who will not wear a mask now is a dangerous slacker.”

‘Extended muzzles’

The streets were filled with people wearing strange get-ups. The Chronicle noted that some masks were “fearsome-looking machines like extended muzzles.”

The standard mask was made of gauze, itself not a particularly effective prophylactic substance. But many people wore masks made of linen, chiffon and other fabrics of dubious or nonexistent effectiveness.

Not all people complied. Hundreds were arrested for not wearing masks. Most paid a $5 fine, but a few were sent to jail. Both Hassler and Mayor Rolph were photographed not wearing masks: Hassler paid a $5 fine, while Sunny Jim was fined $50 by his own police chief.

Police staked out the Ferry Building to nab mask-less commuters. The Chronicle reported that three cops stood on the building’s stairs and “yanked the offenders from the incoming crowd, to the accompaniment of cheers from the onlookers.”

Those seized initially treated the matter as a joke, but “their smiles faded as they were herded into the police office at the Ferry Building and then taken in batches to the Harbor Police Station,” where a captain lectured them on their civic responsibilities.

Three-plus weeks later, the authorities decided the epidemic had slowed enough to rescind the mask law. At noon on Nov. 21, whistles blew and San Franciscans joyously threw their hated masks in the street and trampled on them.

But the reprieve was brief. The epidemic flared up again: In January, 600 new cases were reported in a single day. The city reinstated the mask law on Jan. 17, even though there was increasing evidence that masks didn’t work.

By now, however, the city was fed up. The business community complained, as did private citizens. An “Anti-Mask League,” which included doctors and several supervisors, held a public meeting attended by 2,000 people.

On Feb. 1, the supervisors determined the epidemic was on the wane again, and Rolph rescinded the mask order, this time for good. By fall, the epidemic was history.

In retrospect, the mask order was largely ineffective. Hassler boasted that San Francisco’s response to the flu was exemplary, but he was wrong: The city had one of the highest per-capita death tolls of any American city.

Timothy Leary vaccine

In an odd bit of pharmacological trivia, Hassler imported 17,000 doses of a “famous vaccine” developed by Boston’s medical examiner, one Timothy Leary. The Bostonian was the great-uncle of a more famous Timothy Leary, the best-known proponent of another famous pharmacological substance that swept through San Francisco 50 years later.

The mask law had its amusing side, but the flu epidemic was no joke. Take the story of 13-year-old Ben Broshier.

Ben’s widowed mother moved with him and his younger brother and sister from Tennessee to Oakland, where she opened a grocery store on Telegraph Avenue. She contracted the flu and soon died. Ben was forced to become the head of the family.

A beat cop saw the boy doing the accounts for the grocery store at 5 a.m. Word made its way to Oakland’s police chief, who visited Ben and decided to adopt the boy and his orphaned siblings, declaring them official wards of the Oakland Police Department. “Every policeman will see that Ben gets a square deal,” The Chronicle reported.

This was just one of the countless human stories left in the wake of the great flu epidemic of 1918.

Gary Kamiya is the author of the best-selling book “Cool Gray City of Love: 49 Views of San Francisco,” awarded the 2013 Northern California Book Award in creative nonfiction. All the material in Portals of the Past is original for The San Francisco Chronicle. E-mail: metro@sfchronicle.com

Trivia time

Last week’s trivia question: Where was San Francisco’s first Butchertown?

Answer: Ninth and Brannan streets, on Mission Bay.

This week’s trivia question: What Barbary Coast dance was condemned by the Vatican?

Editor’s note