President Donald Trump's plan to impose a 5% tariff on Mexican goods could cost the U.S. economy more than 400,000 jobs and hit Texas especially hard, according to a new analysis.

"Based on patterns over the past several years, the job loss is roughly equivalent to about two months of recent job gains," said M. Ray Perryman, president and CEO of the Perryman Group, a Texas economic consulting firm.

On Thursday, the White House announced the U.S. plans to slap 5% tariffs on Mexican goods starting June 10. It said it will gradually increase that amount to 25% on Oct. 1 until Mexico "substantially stops the illegal inflow of aliens coming through its territory."

According to Perryman's analysis, proposed tariffs could result in job losses topping 117,000 in Texas and approximately 50,000 in California. The researcher estimates overall job losses in the U.S. from the 5% tariff would reach about 406,000.

The impacts of the administration's trade policies on a red state such as Texas raises potential political risks for Trump ahead of the 2020 presidential election. It also comes amid the ongoing trade war with Beijing that has resulted in a decline in major agricultural exports to China, including soybeans and pork produced in many Midwestern states where Trump enjoyed strong support in the 2016 election.

"Mexico has long been a top trading partner for the United States," said Perryman. "In fact, Mexico recently passed China to become the largest, due in part to trade issues with China which have reduced the volume of US-China trade. To impose a tariff on all goods from our largest trading partner will cause significant cost increases and other harms to the economy."

Perryman's analysis estimates that the largest number of job losses nationally would be in retail trade, followed by manufacturing. The analysis was based on one-year impacts of tariffs if they are imposed and maintained.

"Much is at stake for both nations," the Texas firm's report said. "If Mexico retaliates and imposes tariffs on the U.S., which is likely, the negative effects on the economy would be even greater."

After the Trump administration last year imposed tariffs on imported steel and aluminum from Mexico and other nations, Mexico retaliated with levies on $3 billion of U.S. goods, including cheeses, pork, whiskey and certain fruits. The U.S. threat to slap 5% tariffs on all Mexican goods follows the administration announcing just last month that it struck a deal with Mexico to lift steel and aluminum tariffs.

Mexico has embarked on a campaign to halt Trump's planned tariffs while also expressing hope that they can reach a migration deal with the U.S. Talks are scheduled Wednesday in Washington between Secretary of State Mike Pompeo and Mexico's top diplomat, Foreign Relations Secretary Marcelo Ebrard.

"Texas would bear the lion's share of this loss given the extensive commerce that occurs between the state and Mexico," said the Perryman report.

Last year, Texas imported more than $107 billion worth of goods from Mexico and sold nearly $110 billion of exports. U.S. imports from Mexico last year surpassed $346.5 billion while exports topped $265 billion.

"A 5% tariff on all imports coming to the U.S. from Mexico would likely cause costs to U.S. consumers and businesses to rise substantially," said the report. "People and firms in the U.S. would pay more for Mexico goods because while tariffs are collected at the border, they are largely passed on to consumers and producers."

When adjusted for likely price increases from Mexican goods the U.S. imports, the Perryman analysis estimates the 5% tariff by itself would result in $28.1 billion in increased direct costs annually. The study said costs of tariffs would be felt by American consumers and producers and across supply chains, resulting in negative impacts for the U.S. economy.

Finally, the economic analysis estimates that when multiplier effects are taken into account the 5% tariff on all imports from Mexico could cause a hit of about $41.5 billion to the gross domestic product. It also said there is economic risk longer term given that the new United States-Mexico-Canada Agreement — a replacement deal for the North American Free Trade Agreement — still hasn't been ratified and "negotiations could become more difficult."

— Graphic by CNBC's John Schoen.