Ford, which has been under fire for plans to spend $2.5 billion on a plant in Mexico, has agreed to invest $9 billion in its U.S. plants.

The investment pledge is part of the tentative labor agreement the automaker has reached with workers. The terms of the four-year pact were disclosed by the United Auto Workers union Monday.

The union seeks such commitments from every automaker because they tend to create and protect U.S. jobs.

GM (GM) committed to invest $1.9 billion it its proposed contract with the union, and Fiat Chrysler (FCAU) promised to invest $5.3 billion in the contract it just signed with its workers.

Ford's investment will create or keep about 8,500 jobs over the next four years, according to the union.

Ford (F) has added about 12,000 hourly jobs at U.S. plants in the last four years, bringing its hourly workforce in America up to about 53,000. In 2011 it committed to invest $6.2 billion in U.S. plants and ended up investing $10 billion, adding even more jobs than it had promised.

Related: Donald Trump is wrong about Ford and Mexico

Ford's plans to invest in Mexico have come under attack by Presidential candidate Donald Trump, who has vowed to slap a tax on Ford cars and trucks with Mexican parts if he becomes president.

Aside from the investment, Ford's workers have landed the most generous deal among the big three auto workers.

Ford workers will get a $8,500 signing bonus, compared to $8,000 at GM and $4,000 at Fiat Chrysler, and will receive bigger lump sum payments later in the contract as well. Veteran workers will get a 3% pay raise, their first in a decade, just like at GM and Fiat Chrysler. Additionally, the pay gap between veteran employees and those hired since 2007 will be eliminated over the next eight years.

Related: Americans buying more cars than ever

Next the contract goes to a vote among rank and file UAW members at Ford.

Despite the economic gains the union has won in these contracts, those votes have not been easy so far this fall.

Workers at Fiat Chrysler rejected the first proposed contract they voted upon before approving a second deal reached moments before a strike deadline. And while 55% of workers at GM voted in favor of that deal, opposition to the agreement among skilled trade workers such as electricians and welders, has put the formal ratification on hold there.