After a slow and steady rise, Mexico is now the US’s number-one trading partner.

According to the US Census, for the first six months of 2019, the US and Mexico traded $309 billion worth of goods, just over 15% of all US trade. This puts Mexico just above Canada ($306 billion) and China ($271 billion), making Japan a distant fourth ($110 billion).

If Mexico finishes 2019 as the US’s top trading partner, it will be the first time it will be recorded as ending a year in that spot. The Census estimates trade with major partners going back to 1811 (pdf). Monthly US trade data is available going back to 2002, and Mexico has never been number one after six months.

In 2018, China was the US’s largest trading partner through the first six months, and also ended the year at number one. The US-China trade war has led to a decline in both US exports to China and Chinese exports to the US. With the US set to raise tariffs by 10% on $300 billion worth of Chinese imports in September and Chinese retaliation expected, it is unlikely that China will return to the top spot in the near future.

Mexico’s rise is the culmination of a decades-long trend of the value its trade with the US consistently increasing. At the same time, US exchange with Canada, historically America’s top trading partner, stayed relatively flat—even while US’s overall global trade has increased.

The North American Free Trade Agreement (NAFTA)—which lowered tariffs between the US, Mexico and Canada after it went into effect in 1994—played a role in increasing trade between the US and Mexico. But exchange between the two nations was already growing rapidly through the 1980s and early 1990s. The US and Mexico are natural trading partners given their proximity and their workers’ complimentary skills. Mexico’s cheaper labor means it can export lower-skill manufacturing products and agricultural goods to the US, while the more skilled American workforce sends higher-end products back to Mexico, as well as parts to be used at Mexican manufacturing plants.

Yet Mexico may never have become the US’s top partner if not for Donald Trump’s aggressive stance toward China. From 2015 to 2018, more than 20% of all US imports came from China. As recently as 2002, that number was under 10%. This rise was in large part was a result of China entering the World Trade Organization in 2001, allowing it to export goods to the US more cheaply. Some researchers suggests the increase exacerbated the decline of US manufacturing jobs.

Due to Trump’s tariffs, the value of imports from China to the US dipped from $250 billion in the first six months of 2018 to just $219 billion in 2019. Among the products that saw the largest decline: semiconductors, video game consoles and aluminum, according to a Quartz analysis of US Census data.

China’s tariffs on US goods also have had a dampening effect. US exports to China fell from $64 billion in the first six months of 2018 to just $51 billion in the same period for 2019. Soya beans and petroleum oil were among the products with the largest declines. US exports to Mexico over this time remained about the same.

As the US distances itself from its trade relationship with China, there will be ample opportunities for other countries to fill that gap. Vietnam, South Korea and Taiwan have also seen their share of their trade with the US grow, and as supply chains adjust, that is likely to continue. Yet few country’s exporters have a better chance to take advantage of the US’s reoriented trade approach than Mexico.