President Trump portrays Mexico, China and global trade as the biggest threats to American manufacturing jobs.

"It has been a one-sided deal from the beginning of NAFTA with massive numbers of jobs and companies lost," Trump tweeted on January 26.

His predecessor also offered a warning to American workers, of a different kind.

"The next wave of economic dislocations won't come from overseas. It will come from the relentless pace of automation that makes a lot of good middle class jobs obsolete," President Obama said in his farewell address.

Research supports Obama's claim. Far more jobs are lost to robots and automation -- better technology -- than trade with China, Mexico or any other country.

To be sure, America has lost a lot of jobs to trade, but robots threaten many more traditional, assembly line jobs. There are nearly 5 million fewer manufacturing jobs today than there were in 2000.

Related: U.S. manufacturing job openings back at 2007 levels

MIT professor David Autor found that U.S. trade with China killed 985,000 American manufacturing jobs between 1999 and 2011. And Robert Scott, an economist at the Economic Policy Institute, estimates that trade with Mexico cost roughly 800,000 U.S. jobs between 1997 and 2013.

That might sound high. But consider that last year alone, the U.S. added more jobs than those losses combined. Other research shows robots eat up a much bigger portion of the job-loss pie.

One study by two Ball State University professors found that between 2000 and 2010, about 87% of the manufacturing job losses stemmed from factories becoming more efficient. The chief driver of more efficiency in factories: automation and better technology. The other 13% of job losses were due to trade.

Simply put: it requires fewer workers to make the same amount of cars as it did in 2000. In fact, as the industry has lost workers, the value of U.S. manufacturing production is hovering near an all-time high.

"That to me is first order evidence -- it's not trade," that's taking most jobs away, says J. Bradford Jensen, an economics professor at Georgetown University. "There's been a lot of technical change that has reduced the need for labor -- some of it is automation, some of it is design, more software, less hardware."

So why not crack down on robots if they're driving the job losses?

"It's harder to demonize what everyone sees as technical progress, it's easier to demonize the foreigner," Jensen added.

Related: 40% of a Mexican import is American

Experts stress it's really hard to pin down exactly how many jobs automation has taken away partly because automation also creates new jobs.

MIT professor Daron Acemoglu uses the example of ATMs. They perform the jobs that bank tellers once did. But there isn't much evidence that bank employment tanked as a result of ATMs.

"When tellers stopped doing the cash dispensing, they found more intensive jobs to do," says Acemoglu.

It's a transition that challenges millions of manufacturing workers. The rapid pace of innovation means assembly line workers require higher job skills, experts say. That challenge makes it easy to get left behind.

Related: A 20% tariff would pay for the wall. But Americans would pay it

Another piece of evidence: there were 324,000 manufacturing job openings in November -- about the same level before the Great Recession started in 2007. Experts say many of those open jobs require high skill sets.

Automation is a job creator too. Autor, the MIT economist, found that new technology spurred job growth in some areas even as it ate into assembly line work.

That trend poses a challenge to Trump's goal of bringing manufacturing jobs back from China and Mexico.

"If you prevent that trade now, some of that production might come back, but the employment that comes back will not be for people, it will be for robots," says Acemoglu, the MIT professor.