WASHINGTON — A program that allows foreign students to stay in the United States for temporary employment after graduation has expanded significantly over a dozen years as technical companies stepped up hiring of science and engineering majors, according to a report.

The study by Pew Research Center in Washington comes as colleges and universities across the country struggle with falling enrollment by foreign students amid the Trump administration’s anti-immigration rhetoric and policies.

In 2016, 172,000 foreign nationals who went to college or university in the U.S. got a job through the Optional Practical Training program compared to 45,000 in 2004, according to the report. Participation in the program surged after President George W. Bush and then President Barack Obama extended the length of stay for science, technology, engineering and math majors.

Neil Ruiz, a co-author of the report, says the program has been key in attracting foreign students to study in America and keep them here after they graduate. U.S. universities have the largest foreign student population in the world.

According to a separate study by the Association of International Educators, foreign students contributed $37 billion in tuition and living expenses to the U.S. economy in the academic year 2016-2017.

“It is very important to remember that we are in a global competition for talent,” said Jill Welch, the association’s deputy executive director for public policy. “We do not have to lose these talented and valuable international students to other nations.”

But enrollment has been dropping. The Institute of International Education found that the number of new college students coming to the United States from overseas fell by 7 percent since Donald Trump was elected president. The group attributes the decline to his travel restrictions for nationals of some predominantly Muslim countries as well as competition from countries like Canada, Australia and Britain. And the Trump administration is also considering changes to the temporary employment program. Although no details on the changes have been released, Trump generally has championed prioritizing American workers.

Rajika Bhandari, head of research at the Institute of International Education, said the program has successfully attracted science and engineering talent to the United States and boosted science research and innovation. If the program is scaled back, she warns, those students might choose other destinations.

“The US will significantly lose its edge in science and innovation if international students in the sciences and engineering chose to go to other countries that have very strong and attractive post-study opportunities,” Bhandari said.

Brad Farnsworth, vice president at the American Council on Education, a group representing 1,800 college and university presidents, agrees.

“It’s good for international students, it’s good for employers, it’s also good for the U.S. institutions that are trying to be more attractive to international students,” he said.

But David North, a fellow with the Center for Immigration Studies, argues the program puts Americans at a disadvantage. Workers in the jobs program and their employers don’t have to pay Medicare and Social Security taxes, so the companies would have a financial incentive to hire an OPT student as opposed to a U.S. citizen, he says.

“Foreign worker programs in general, including OPT, should not be encouraged because it takes jobs from US workers that they could easily perform,” North says. “They should rethink the program completely, and they should certainly remove the subsidy.”