VW considered closing up to three factories in Germany and urged its employees to accept a 10% pay cut.
At the time, the union called for a 7% increase.
Although the deal will also reduce production capacity at the factories, this has been noted by union leaders.
“No site will be closed, no one will be fired for labor reasons, and the pay agreement in our company will be fixed for the long term,” said IG Metall works council head Daniela Cavala.
“We have reached a solid solution in the most difficult economic environment,” she added.
35,000 job cuts are expected to be found by 2030 through various solutions such as proposed early retirement.
Under the agreement, the 5% wage increase previously agreed upon will also be suspended in 2025 and 2026.
The union said it would help “support transformation” at the company.
From 2026 in Germany, the number of apprenticeships offered each year will be reduced from 1,400 to 600, and some production will be moved to Mexico.
It is also considering alternative options for its sites in Dresden and Osnabruck.
But Oliver Blum, chief executive of VW Group, said in a statement that the agreement was “an important signal for the future viability of the Volkswagen brand”.
The closure of factories in Germany would be unprecedented in the history of the manufacturer.
VW, like other German automakers, has been hit hard by a decline in demand for its cars in China, a previously lucrative market.
At the same time, Chinese brands are moving into Europe, increasing competition for sales.
During the negotiations, about 100,000 workers joined short, so-called “precautionary strikes” at factories across the country to put pressure on company management.
The latest round of talks began on Monday, with negotiators apparently determined to settle matters before Christmas.
German Chancellor Olaf Scholz also welcomed the announcement, calling it a “good, socially acceptable decision.”