Under the deal, salaries will increase in two steps over the next year: a 3.4 percent rise in July and a further 2.2 percent rise in May 2014, the two parties said in statements.
IG Metall had sought a 5.5 percent pay rise this year. The Gesamtmetall employers association had originally offered a 2.3 percent rise over a slightly different timeframe.
"With this deal, workers are being treated in a fair and appropriate way, in line with the economic situation," said IG Metall president Bertold Huber.
The union had warned on Sunday that metal workers would vote on major strike action if no agreement was reached this week.
Nearly 400,000 workers had already joined a wave of limited "warning strikes" in recent days, hitting big German companies including BMW, Siemens and Bosch.
IG Metall is Europe's largest union with more than 2.2 million members. Pay talks in the metalworking sector are closely watched because they set the tone for other industries.
The union sought the pay rise for 3.7 million metalworkers spread across different branches, from automobiles to electronics.