WASHINGTON—Imposing stiff tariffs on China and Mexico, as Republican presidential nominee Donald Trump has proposed, could push the U.S. into recession and cost 5 million U.S. jobs, according to a study by the Peterson Institute for International Economics.

The Peterson Institute, a Washington, D.C., think tank that favors free trade, ran three computer simulations of the economic impact of placing 45% tariffs on Chinese goods and 35% tariffs on Mexico’s. Under the most dire outcome, China and Mexico would retaliate with tariffs on U.S. goods and services, U.S. exports and imports would shrink, import prices would rise, stock prices would tumble and investment would plunge, resulting in recession within three years.

The Peterson study looks at the impact down to the county level, finding that Los Angeles County and Chicago’s Cook County would lose the most jobs. Three counties in New York City—Brooklyn, Queens and Manhattan—would also be especially battered. Among the states, Washington state would suffer the largest percentage job decline, followed by Massachusetts and California.

Hillary Clinton’s trade policies would also be costly—though far less so than Mr. Trump’s—the Peterson study said. She would block the Trans-Pacific Partnership, a trade pact negotiated among a dozen Pacific rim nations, including the U.S., Japan and Vietnam, which she had touted as secretary of state. Mr. Trump also opposes the TPP, as do many congressional candidates in this year’s election.

President Barack Obama has made the trade deal, which Peterson estimates could boost the U.S. economy by as much as $130 billion, a priority and wants Congress to pass it in a legislative session after election day.