Details of the agreement were not immediately available. The deal was confirmed by Terry Dittes, the UAW's chief negotiator with GM.

The tentative agreement needs the approval of both union leadership as well as the rank-and-file union members at GM before it can take effect. UAW officials from across the country were already set to meet in Detroit on Thursday. That had been taken as a sign that the two sides were getting close to a deal

It is not yet certain when workers will start returning to work. The union statement say it will be decided at Thursday's meeting whether they should return to work or remain on strike until the rank-and-file ratification vote takes place. The ratification process can take a week or more to complete.

"The No. 1 priority of the national negotiation team has been to secure a strong and fair contract that our members deserve," said Dittes.

The strike has been the largest at a US business since the last strike at GM in 2007. But that strike was over within three days. This is has been the longest major strike in the auto industry in more than 20 years.

It could be difficult to win rank-and-file approval for the deal, although strikers will probably want to return to work after missing four weeks of paychecks. But membership has been known to reject tentative agreements reached by union leaders. That happened in the last round of auto contract talks four years ago when members at Fiat Chrysler rejected the initial deal presented to them.

GM was careful not too say too much about the deal, perhaps out of concern that praising it would convince some workers that it was too much in the company's favor.

"We can confirm the UAW's statement regarding a proposed tentative agreement. Additional details will be provided at the appropriate time," said GM's lone statement on the agreement.

GM GM But GM investors liked the news. Shares ofrose were up nearly 2% in midday trading, with most of the gain on the news of the deal. Shares of GM are still down 5% since the start of the strike.

The strike has halted work at 31 GM factories and 21 other facilities spread across nine states, mostly in the middle of the United States. It also led to layoffs at other GM plants in Mexico and Canada that had to shut because of the disruption in their supply chains. Many of the 10,000 US suppliers that provide auto parts and other goods and services to GM laid off staff as well. That may have idled as many as 200,000 additional workers at those companies, according to estimates.

If the strike ends this week, GM will have lost about $1.5 billion in profit , according to an estimate from the Anderson Economic Group. The group also estimates that strikers have lost about $800 million in wages. Last weekend, the union raised strike benefits 10% to $275 a week . But that is still far less than the more than $30 an hour that veteran workers receive when on the job at GM.

The union demanded some of the vehicles that GM is now building in Mexico shift back to the US factories. GM announced plans to close four US plants last November. Those plants had about 3,000 UAW members on payroll at the time of the closing announcement. GM said it has found other jobs for about 2,300 of those workers, but many had to relocate to take those other jobs.

The company has offered to to invest $8.3 billion in GM plants, according to a person familiar with the talks. That's an increase of more than $1 billion from its offer at the start of the strike. It said such investment would create or protect about 5,400 jobs. But the union had continued to push for vehicles to be shifted back from GM plants in Mexico , where it built about 800,000 cars and trucks last year.

The union and management also had been split on GM's use of temporary workers, who get lower wages and fewer benefits than permanent employees. GM said Friday that its offer included a way for those temporary workers to become permanent GM employees. GM said it offered pay raises or lump sum payments for UAW members for each of the four years of the contract, as well as improved profit sharing and a signing bonus.

GM and other automakers are dealing with declining US car sales along with the need to spend billions to develop electric and self-driving vehicles which are seen by many as the future for the industry. GM has said much of the $6 billion a year it hopes to save from plant closings would be invested in those research and development efforts.

But GM has remained very profitable , even in the face of declining sales in both the United States and China, now it's largest market for car sales. The union has said its members made sacrifices to save the company 10 years ago as it went through bankruptcy and bailout. It argues that given the record profits it has reported since then, the workers deserve to be compensated for those sacrifices.

Talks had taken numerous twists and turns before Wednesday's announcement. The two sides seemed to be getting close to an agreement two weeks ago, but on October 6 the UAW sent an update to membership saying that negotiations had taken a " turn for the worse ."