Americans craving kung pao chicken or a good lo mein for dinner have plenty of options: The U.S. is home to more than 40,000 Chinese restaurants.

One could think of this proliferation as a promise fulfilled — America as the great melting pot and land of opportunity for immigrants. Ironically, the legal forces that made this Chinese culinary profusion possible, beginning in the early 20th century, were born of altogether different sentiments: racism and xenophobia.

Anti-Chinese sentiment was rampant in America in the early 20th century — and had been since the latter half of the 19th century, when as many as 300,000 Chinese miners, farmers, railroad and factory workers came to the U.S. Many non-Chinese workers felt threatened by these laborers, who often worked for lower wages.

Amid mounting social tensions, the U.S. passed immigration laws that explicitly barred Chinese laborers from immigrating or becoming U.S. citizens, and made it extremely difficult for even legal residents to re-enter the U.S. after a visit home to China.

But, as MIT legal historian Heather Lee tells it, there was an important exception to these laws: Some Chinese business owners in the U.S. could get special merchant visas that allowed them to travel to China, and bring back employees. Only a few types of businesses qualified for this status. In 1915, a federal court added restaurants to that list. Voila! A restaurant boom was born.

"The number of Chinese restaurants in the U.S. doubles from 1910 to 1920, and doubles again from 1920 to 1930," says Lee, referring to research done by economist Susan Carter. In New York City alone, Lee found that the number of Chinese eateries quadrupled between 1910 and 1920.

Lee was digging through old immigration records in 2011, as part of her doctoral dissertation, when she discovered evidence that this legal change had fueled a rise in restaurants. She found a flood of applications from Chinese immigrants after 1915 seeking merchant status to start up restaurant businesses, along with applications from others brought over to work in these establishments.

Prior to the restaurant loophole, Lee says, most Chinese immigrants in America worked in laundries — they were excluded from better-paying options. But by 1930, they were more likely to be toiling in eating establishments. "The scale of it increases astronomically," she says.

Many Chinese immigrants to the U.S. were men who had come alone: They were here to earn money to support families back home, not to settle down permanently. Once in the U.S., however, it was all but impossible for them to travel back to visit loved ones in China. After 1915, the visas that came with working in a restaurant became bridges to families and friends back in China, Lee says.

"It was really important for [these men] to be able to move back and forth, to get married and retire someday. That was the idea. These special visas were critically important," Lee says.

Even so, getting a special merchant visa was far from easy, Lee explains. Only the major investors in a restaurant qualified — and it had to be a "high grade," fancy eatery. These investors had to manage their restaurants full time for at least a year. During that time, they couldn't do any menial work: no cooking, waiting tables or ringing up the cash register, she says.

Lee says Chinese immigrants found ingenious ways to get around these hurdles: They would pool their money to start luxury "chop suey palaces," then each investor would take turns running the joint for a year or 18 months. Once they'd earned merchant status, the investors would use it to bring their relatives over to work in the restaurant.

Lee explains how it worked: "Your cousin, your uncle has helped you over and is giving you a job. He's supposed to show you the ropes. Then you move up the hierarchy until you earn the money to be a partner in your own restaurant."

Lee's research focused on New York City (she's writing a book about the rise of restaurants there in the 19th and early 20th centuries). But she says the immigration dynamics were similar in other urban centers with large Chinese communities, like Chicago and San Francisco.

In order to make these schemes work, Chinese restaurateurs also had to loop in the white vendors they worked with: Lee says Chinese immigrants had to have two white witnesses support their visa applications. In practice, she says, this turned into a quid pro quo situation: A small group of white vendors would secure the restaurants' business, and in exchange, they'd vouch for the investors. "I found the same six vendors' names over and over again" on old immigration documents, she says.

"It's quite a different story than [the usual explanation] about why Chinese were opening restaurants during that period," Lee tells me.

That standard explanation points to a confluence of cultural forces. For one thing, as historian Yong Chen notes in Chop Suey, USA, Chinese food's cheapness made it an affordable luxury and helped democratize the dining out experience.

The late hours observed by Chinese restaurants were also a draw — especially to bohemians, whose patronage lent these establishments a certain cachet. By 1910, "going out for chop suey made middle-class Americans feel pleasantly naughty," write Lisa Stoffer and Michael Lesy in Repast, their history of dining out during that era.

Cultural historians also tell of the rise of "slumming parties" — groups of well-heeled suburbanites and out-of-towners in New York who'd pay for tours of Chinatown, where the supposed "depravity" of the place was the main attraction. And some point to New York Jews who shook off the old country and embraced Chinese food as a sign of their own modernity.

All of these factors played a role, Lee says, but they're not the whole story. "While going to Chinese restaurants did play into an emerging worldview, what's really under-recognized is the primary motivation for the Chinese," Lee tells us.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.