But the moves raise questions about how competitive the country’s auto industry can be if its manufacturing options shrink in Mexico, and what the implications will be for consumers. For now, at least, some executives are praising Mr. Trump’s economic plans.
“We are encouraged by the pro-growth plans that President-elect Trump and the new Congress indicate they will pursue,” Mark Fields, Ford’s chief executive, said at an event on Tuesday.
The decision by Ford to drop plans for a new plant in Mexico — what would have been a $1.6 billion investment — came at the same time the company announced it would add 700 jobs to build electric and hybrid vehicles at a plant in Flat Rock, Mich.
The new Mexican factory was to build Ford Focus sedans currently manufactured at another Michigan plant near Detroit. Now the company will build those cars at an existing plant in Mexico.
Ford officials said that the revised plans were tied to market conditions that have depressed small-car sales, and that they did not consult with the incoming Trump administration before making the decision.
They did, though, tell Mr. Trump about the change just before the announcement. And on Tuesday, Mr. Fields made clear that Mr. Trump’s policies were playing a role in the company’s thinking. He added in an interview that the president-elect’s emphasis on tax changes and cutting regulations should have an overall positive effect on automakers such as Ford.
“We have a president-elect who has said very clearly that one of his first priorities is to grow the economy,” he said. “That should be music to our ears.”
Ford has been a target of Mr. Trump’s criticism since last spring, when he singled the company out during his campaign for planning to create jobs in Mexico instead of pushing employment in the United States. After the election, Ford dropped plans to move production of a Lincoln S.U.V. to Mexico from Kentucky. That move followed discussions between Mr. Trump and William C. Ford Jr., the company’s chairman.
One industry analyst, Ron Harbour of the consulting firm Oliver Wyman, said Ford was under intense pressure to alter its Mexican plans — or risk a constant drumbeat of criticism from Mr. Trump.
“It was an embarrassment for them, and they said, ‘Let’s turn this thing around,’” Mr. Harbour said.
Now Mr. Trump has turned his attention to G.M. In a Twitter post early Tuesday, he attacked the company for making a hatchback version of a Chevrolet in Mexico for sale in the American market.
“General Motors is sending Mexican made model Chevy Cruze to U.S. car dealers tax-free across the border,” Mr. Trump wrote. “Make in U.S.A. or pay big border tax!”
A central tenet of Mr. Trump’s economic platform has been to renegotiate the North American Free Trade Agreement, which allows for the free flow of manufactured goods between the United States, Canada and Mexico. Instead, he favors tariffs of up to 35 percent on products made in Mexico and sold in America.
Industry analysts have questioned whether automakers like G.M. and Ford can profitably build smaller vehicles in the United States instead of in Mexico, where wages rarely cross $10 an hour, compared with the $29 an hour earned by a majority of unionized American workers.
For consumers, those higher wages could add up to higher sticker prices. And that could potentially reduce sales.
But Mr. Trump is hardly backing off on his vow to scrap Nafta, and has found an unlikely ally in the powerful United Automobile Workers union, which represents hourly employees at G.M., Ford and Fiat Chrysler in the United States.
While the U.A.W. leadership supported Mr. Trump’s rival, Hillary Clinton, in the presidential election, the union has consistently attacked Nafta for encouraging car companies to invest in Mexico.
“The U.A.W. has long believed that companies that sell in our country should build their products in our country,” the union’s president, Dennis Williams, said on Tuesday.
The hatchback made by G.M. in Mexico is a version of its Cruze compact car produced primarily at a factory in Lordstown, Ohio.
Sales of the Cruze, like many other passenger cars, have fallen in recent months because of low gas prices and shifting consumer demand toward more spacious sport utility vehicles. The Lordstown factory is among five American plants that G.M. will temporarily idle this month to reduce its growing inventories of slow-selling cars.
G.M. officials declined to comment on Mr. Trump’s Twitter attack, other than to say in a statement that only a “small number” of Cruze hatchbacks were built in Mexico for the American market.
But G.M. has a large exposure to any potential changes looming on Nafta, having committed up to $5 billion in long-term investment in Mexico. Foreign car companies like Volkswagen and Toyota are also adding jobs and new products at their Mexican facilities.
With Nafta under fire from the incoming administration, Ford, in particular, has tried to adapt.
In a recent interview, the company’s chief financial officer, Robert L. Shanks, said the automaker was expecting changes in trade deals, and increasing its focus on expanding its manufacturing in the United States. “The bigger principle is we want to grow the U.S. economy,” he said.
On Tuesday, the company packaged a series of announcements on new electrified vehicles with a promise to invest $700 million in its Flat Rock assembly plants.
The addition of 700 jobs at the plant will help it build a new fully electric S.U.V. to debut in 2020, as well as a new autonomous vehicle that has no steering wheel and operates entirely by computer.
Ford’s vice president of global purchasing, Hau Thai-Tang, said the company chose the Flat Rock facility “to really show we are making a commitment to the United States and to technology.”
Mr. Fields, however, was more circumspect on why the company had dropped its plans for the new Mexican factory. “We didn’t need it anymore,” he said. “We just don’t need the capacity anymore given the demand for small cars.”
Still, the news about the Mexican plant and the new jobs in Michigan were conveyed directly to Mr. Trump and Vice President-elect Mike Pence before they were publicly announced.
“We called the president-elect and the vice president-elect this morning and gave them the news,” Mr. Fields said Tuesday. “They were very pleased, obviously, that we were making these investments in the U.S.”