MEXICO CITY—Demand in America for Mexican farmhands, landscapers and other temporary workers is surging as the Trump administration moves to curb immigration and renegotiate its trade relationship with Mexico.

That demand is prompting both countries to search for ways to ease labor shortages in key parts of the U.S. economy.

In the first nine months of fiscal 2017, which began Oct. 1, the U.S. Labor Department certified more than 160,000 temporary workers—the bulk of them from Mexico—to harvest berries, tobacco and other crops in the U.S. under the H-2A agricultural visa program. That was up 20% from the period a year earlier.

The annual issuance of H-2A visas nearly doubled from 85,248 in fiscal 2012 to 165,741 in 2016. The U.S. doesn’t cap the number of these visas.

Outside of agriculture, use of another type of seasonal-work visa also has surged in response to increased U.S. demand for unskilled laborers such as hotel housekeepers. The Department of Homeland Security in July raised the annual cap on H-2B visas by more than 20% to 81,000. The majority of workers receiving this type of visa also are from Mexico.