General Motors chief executive Mary Barra, center, listens to a question from a reporter during an event at the Orion Assembly plant in Orion Township, Mich., on March 22, 2019. (Jeff Kowalsky/Bloomberg News)

General Motors announced a substantial new investment at a Michigan factory Friday that the automaker says underscores its commitment to building vehicles and creating jobs in the United States.

President Trump berated GM all week for closing a big plant in Lordstown, Ohio, with the loss of about 5,400 jobs. GM’s announcement Friday was tailored to appease Trump, but the investment is not a direct result of his pushing, according to two people familiar with the matter, who spoke on the condition of anonymity because they were not authorized to comment publicly.

Auto companies spend years drawing up plans for what vehicles to build and where. They have to negotiate with the United Automobile Workers union and with state and local governments over many details, making it impossible to roll out anything in a matter of days as Trump demanded in a phone call with GM chief executive Mary Barra on Sunday.

GM is pumping $300 million into its Orion Assembly plant in the Detroit suburbs to build a new electric car. The company did not disclose any details about the car but did say 400 jobs would be added at the Orion factory, which already makes the electric Chevy Bolt and a self-driving vehicle.

Barra, wearing safety glasses, spoke Friday at the Orion factory alongside UAW leaders and workers. She said the expansion in Michigan is part of a $1.8 billion investment in the United States. About $1.4 billion of that is money that was not previously announced.

The domestic investment comes on the heels of an announcement this week that GM is spending $2.7 billion to expand its production in Brazil.

Auto industry experts point out that GM’s contract with the UAW expires in September, and it is typical for major automakers to announce sizable new investments around this time as the companies and the union agree on pay and production details for the next several years.

In the spring of 2015, GM announced $2 billion in additional investments, according to the Center for Automotive Research, but many of the details about which plants would get the money did not come out until after the union agreement had been finalized.

“We’re probably looking at a couple of years of discussions for GM to get to this point to be able to make Friday’s announcement,” said Kristin Dziczek, a vice president at the Center for Automotive Research.

GM hoped to assuage Trump, but the company did not commit to anything in Ohio.

Trump did not tweet about GM’s announcement Friday, a notable difference from his praise for Ford earlier in the week after that automaker said it would invest $1 billion at a facility in Michigan.

But Larry Kudlow, head of Trump’s National Economic Council, said the GM news is welcome. He spoke with Barra on Thursday about it.

“It’s a big plus. There’s no two ways about it,” Kudlow said. “GM is building in America, and they’re investing in America.”

Trump had demanded that Barra either reopen the Lordstown facility immediately or sell it to another company that would build something else in the massive plant, which has been a bedrock of eastern Ohio’s “Steel Valley” since 1966.

“And what’s going on with General Motors? . . . Sell it to somebody or open it yourselves. Get it going now, and the UAW will help you,” Trump said Wednesday on a visit to Ohio.

The Lordstown area had voted for Democrats for president for decades before swinging to Trump after he promised to bring jobs back from abroad.

“Lordstown is a great area. I guess I like it because I won so big there,” Trump said Wednesday.

The manufacturing sector added the most jobs last year since 1997, according to Labor Department data, with many corporations crediting the president’s tax cuts and deregulation policies, although most are not fans of his tariffs on steel and aluminum.

Trumbull County, where Lordstown is located, has not benefited as much from the strong economy in recent years. The unemployment rate in the county is 7.7 percent, more than double the national rate and little changed from 8.1 percent when Trump took office.

The president has made clear he wants another vehicle produced in Lordstown.

In the phone call with Trump, Barra tried to explain that the fate of the Lordstown plant will be decided this year when union negotiations are finalized, but Trump didn’t like that response, according to two people familiar with the call.

GM cast the news as an indication that the company is embracing the new United States-Mexico-Canada trade agreement, which incentivizes production of vehicles in North America.

“We are excited to bring these jobs and this investment to the U.S.,” Barra said Friday.

But some Ohio lawmakers were not satisfied with Friday’s GM announcement. “After GM pocketed billions of dollars in tax cuts, they can certainly afford to do right by their workers, retool the Lordstown plant and invest in the Valley as they did in Orion Township today,” said Sen. Sherrod Brown (D-Ohio).

GM workers in Lordstown face a difficult choice of whether to seek other jobs in the area, go back to school to retrain or accept GM’s offer to move elsewhere in the country.

Though GM has allowed several hundred Lordstown workers to transfer voluntarily to other factories, some are being sent letters that say a worker must transfer or else be restricted to working only at the GM Lordstown plant in the future, a risky bet, since the facility might not reopen.

“It’s just a very stressful place to be,” said David Green, president of UAW Local 1112 in Lordstown. “We’ve had like 100 people getting letters forced to transfer to Wentzville, Missouri. They said no. They are just not interested.”