For more than five decades in the 19th and early 20th centuries, sex slavery was openly practiced in San Francisco.

Young women who had been kidnapped or purchased in their native China were shipped across the ocean and forced to become prostitutes in Chinatown. Broken by disease and despair, few survived more than five or six years of slavery. City officials knew about this appalling trade, but did little to stop it. It is one of the darkest chapters in San Francisco history.

The sex-slave trade came about because of several factors. The Chinese men who immigrated to California during the Gold Rush did not intend to stay: They planned to make their fortune and return home. As a result, although more than half of the Chinese immigrants were married, almost none of them brought their wives or families.

According to Judy Yung in “Unbound Feet: A Social History of Chinese Women in San Francisco,” in 1850 only seven of the 4,025 Chinese in San Francisco were women. Further discouraging women from emigrating was Confucian ideology, which had held sway in China for almost 2,000 years and dictated that women should be subordinate to men and should not leave the domestic sphere.

The absence of women created a market for prostitution. A few Chinese prostitutes at the start of the Gold Rush were independent agents, but the vast majority were slaves or indentured, which in practice amounted to the same thing. Procurers working for brothel owners in San Francisco scoured the Chinese countryside for young women, whom they kidnapped, lured, or purchased and shipped to San Francisco.

Because girls were considered inferior to boys, and could not carry on the ancestral line, families were willing to sell them, mortgage them, or simply kill them if economic circumstances dictated. As Lucie Cheng Hirata notes in “Free, Indentured, Enslaved: Chinese Prostitutes in 19th Century America,” an article that appeared in the autumn 1979 issue of the journal Signs, girls often accepted being sold out of filial loyalty. In any case, few were in a position to oppose their family’s decision.

Others were lured by promises of gold, marriage, education or jobs. Hirata writes, “Sometimes the victims were invited to see the big American steamer anchored at the docks, and while they were enjoying the tour, the boat would sail off to San Francisco.” But generally such ruses weren’t necessary — the girls were simply kidnapped by force.

After being shipped to San Francisco, these young women and girls were taken to a barracoon — a temporary holding pen — on St. Louis Alley in Chinatown. If they had already been purchased, they were turned over to their owner; otherwise, they were stripped for inspection and sold to the highest bidder.

According to Herbert Asbury in “The Barbary Coast,” the highest price paid was $2,800 for a girl who was 14, the age widely considered then to be the best for prostitution. Little girls were also purchased and used as household slaves until old enough to become prostitutes or concubines. Since the young women were often acquired in China for as little as $50, the human trafficking was extremely lucrative.

The young women were forced to sign papers they did not understand, agreeing to become prostitutes for four to six years to pay off their passage. The most attractive women became the concubines of wealthy owners and were sometimes treated decently, although if they failed to please their masters they could be returned to the auction block. Others ended up in higher-class brothels reserved for Chinese men, where they also received somewhat better treatment. (Hirata notes that Chinese men believed that the most degrading thing a Chinese woman could do was have sex with a white man.)

But large numbers ended up in cribs, shacks frequented by sailors, teenage boys, laborers and drunks, Chinese and white alike, who paid 25 to 50 cents for their services. Subjected to dreadful treatment by both owners and customers, most of them contracted venereal diseases and were physically and mentally broken within a few years.

At this point, a dreadful ritual took place. The Chronicle reported in 1869, “When any of the unfortunate harlots is no longer useful and a Chinese physician passes his opinion that her disease is incurable, she is notified that she must die.” She was then carried to a “so-called hospital,” a dismal, windowless, unfurnished room in a back alley of Chinatown.

“A cup of water, another of boiled rice, and a little metal lamp are placed by her side,” The Chronicle reported. The proprietors of the “hospital” then locked the door. When the lamp had gone out, they entered and removed the woman, who was usually dead from starvation or by suicide.

But even if she was still alive, she was removed and disposed of: “They come for a corpse,” The Chronicle said, “and they never go away without it.”

In other cases, the sick prostitutes were simply put out on the street to die. In 1870, the Alta newspaper reported that the bodies of dead prostitutes littered the streets of Chinatown. Some chose to commit suicide by eating raw opium or jumping into the bay.

Hirata estimates that nearly all the Chinese women in San Francisco in 1860 were prostitutes, and that a decade later the total was still 70 percent. The sex trade was highly lucrative: A brothel owner could make $2,500 a year on each girl he owned, five times more than the $500 average income of other occupations open to Chinese.

Like the other major vice rackets in Chinatown, gambling and opium smoking, prostitution was controlled by the tongs, which had started out as legitimate associations but became criminalized secret societies. The Hip Yee Tong, which started the trafficking in 1852, imported 6,000 women and made an estimated $200,000 profit from it between 1852 and 1873.

San Francisco officials were well aware that the brothels of Chinatown were a moral outrage. But despite some efforts to fight the human trafficking, the city mostly looked the other way — and even at times worked with the tongs to ensure their human cargo was delivered to them. That story will be the subject of the next Portals.

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

Trivia time

The most recent trivia question: Why were the streets of 1849 San Francisco strewn with shirts?

Answer: It was cheaper to buy a new shirt than to launder a dirty one.

This week’s trivia question: What was the range of the 16-inch guns at Battery Davis in Fort Funston?

Editor’s note

Every corner in San Francisco has an astonishing story to tell. Gary Kamiya’s Portals of the Past tells those lost stories, using a specific location to illuminate San Francisco’s extraordinary history — from the days when giant mammoths wandered through what is now North Beach to the Gold Rush delirium, the dot-com madness and beyond. His column appears every other Saturday, alternating with Peter Hartlaub’s OurSF.