American universities are enrolling unprecedented numbers of foreign students, prompted by the rise of an affluent class in China and generous scholarships offered by oil-rich Gulf states such as Saudi Arabia.Cash-strapped public universities also are driving the trend, aggressively recruiting students from abroad, especially undergraduates who pay a premium compared with in-state students.

There are 1.13 million foreign students in the U.S., the vast majority in college-degree programs, according to a report to be released Wednesday by the Department of Homeland Security. That represents a 14% increase over last year, nearly 50% more than in 2010 and 85% more than in 2005.

Students from China account for the largest share—331,371 of all international students, or 29%. Nearly 81,000 subjects of the Saudi kingdom are studying in the U.S. this school year, up from about 5,000 in 2000-01. Nearly three-quarters of Saudi students are enrolled in bachelor’s programs or English-language programs that precede starting undergraduate studies here.

Of the top five campuses for international students, two are public universities: Purdue, at No. 2, and the University of Illinois Urbana-Champaign, at No. 4. The No. 1 school is the University of Southern California, with 12,480 students, according to the report. Columbia ranks No. 3. and New York University comes in at No. 5.

Amid rising costs, shrinking state support and student resistance to tuition increases, foreign students have become crucial to many public universities. Some hire foreign consultants to recruit students overseas, while others send their own staff on scouting missions. Officials at many state universities say the higher-paying students essentially subsidize in-state students.

But the perception that foreign students, in addition to out-of-state Americans, displace state residents has fueled a backlash in some states.

The University of California system recently announced it will cap the percentage of out-of-state and foreign undergraduate students at the Los Angeles and Berkeley campuses at the current level, 22%. University of Iowa regents last year adopted a plan to tie state funding of public universities to the number of in-state students enrolled.

Brenda Nard of Salem, Ore., said she encountered many out-of-state and foreign students during her daughter’s recent college search. “You wrestle with it because you want your kids to have the most opportunity,” she said. “I understand the state needs the money yet I also wonder if it eliminates opportunities for some Oregonians.”

Tina Orwall, a Washington state legislator, in 2012 introduced an amendment to a tuition bill that allowed the University of Washington to increase enrollment as long as the number of in-state residents remained at a minimum level. The amendment, prompted by an influx of both foreign and out-of-state students, passed.

“I was hearing from constituents that their sons and daughters were being denied admission into our state institutions despite being very strong academic students,” she said.

The growth in international students also has caused tensions on some campuses. At Michigan State University, where the Chinese undergraduate population has risen eightfold in nine years to nearly 4,000, staff and students have been promoting dialogue since luxury cars owned by Chinese students were vandalized in 2012.

“There is a widespread notion that dollars are being spent on foreign students and that they are displacing U.S. students, even if in general that isn’t right,” said John Bound, a University of Michigan economist who has studied the influx.

U.S. research universities have long attracted foreigners, typically graduate students on a tight budget who fund their advanced degrees with fellowships and teaching jobs.

After the terrorist attacks of Sept. 11, 2001, the U.S. restricted student visas. Now, the foreign student population is booming. In particular, “the undergraduate [international] phenomenon has just exploded,” said Mr. Bound.

Some lawmakers are encouraging the trend. In Colorado, legislators passed a law in 2010 that exempts state colleges from a 45% cap on out-of-state students.

The University of Colorado Boulder has a goal for international students to represent 10% of the student population in the next three to five years, up from 6.5% currently. CU’s top three foreign countries for undergraduates today are China, Saudi Arabia and Kuwait, respectively.

“We are relatively new to the game,” said CU Boulder admissions director Kevin MacLennan. Last fall, he dispatched staff to 40 countries in a recruitment drive. For the 2015-16 school year, the university saw a 41% jump in international applications for its freshman class. Mr. MacLennan said international students fulfill a vision of “globalizing” the campus. They are also a financial boon, as state funds dwindled to 4% of the university’s budget last year from 12% in 2000.

International undergraduates pay $35,231 annually in tuition and fees, compared with $10,971 for Colorado residents and $33,333 for out-of-state U.S. students.

Unlike many foreigners who earn advanced degrees, most international undergrads say they are committed to returning home after their studies.

“Why would I stay? I don’t have connections here,” said Jinxin Li, a junior studying economics at CU Boulder. “In China, my father knows people; it’s easy to do business.”

Students from countries whose governments pay for their education, such as Saudi Arabia, are obligated to return home.

U.S.-educated Saudis “help direct [their] country toward more openness, broader political freedom and inclusion,” said Daniel Benjamin, a foreign-relations scholar at Dartmouth College.

But, adds the former State Department counterterrorism coordinator, “we shouldn’t imagine that it is risk-free” to offer such students exposure to U.S. values.

The late Egyptian Sayyid Qutb, considered to be the father of modern jihadist thought, shaped his anti-American views just an hour’s drive from Boulder while attending college in Greeley, Colo. And three years of study in North Carolina didn’t divert Kuwaiti Khalid Sheikh Mohammed, the operational mastermind of 9/11, from the extremism he had embraced as a teenager, Mr. Benjamin noted.

Yet many scholars say attracting international students is vital to U.S. geopolitical interests. Foreign graduates often become agents of “soft power,” helping spread U.S. values, they say.

“Being engaged with so many different people has changed me,” said Suffyanah Algheithy, a Saudi student at CU Boulder.

Hatem Farag, an undergraduate business major at CU Boulder, said: “Getting out of my comfort zone, which is Saudi Arabia, has enabled me to understand different cultures and perspectives, to add something new to the social dialogue when I finish my education and go home.”