President Donald Trump's Treasury secretary and top trade advisor opposed his surprise plan to impose new tariffs on Mexican imports, according to a source close to the White House who said the idea was pushed by immigration hawk Stephen Miller.

The announcement came as Trump was "riled up" by conservative radio commentary about the recent surge in border crossings, according to the source.

Trump made the announcement Thursday night on Twitter. He said he will impose 5% tariffs on all Mexican imports starting June 10 and escalate them to 25% "until such time as illegal migrants coming through Mexico, and into our Country, STOP."

Anticipation that the tariffs combined with an escalating U.S.-China trade war could cool global growth sent equities sharply lower Friday, with the major U.S. indexes off by 1% in afternoon trading.

The opposition by Treasury Secretary Steve Mnuchin and U.S. Trade Representative Robert Lighthizer marked a rare moment of unity from two top administration officials with starkly different economic ideologies.

Miller's role was confirmed by the source close to the White House and a person briefed on the matter.

Trump's move was announced as the administration's most prominent free-trade advocates — including economic aide Larry Kudlow and Vice President Mike Pence — were not around to argue against it. Pence was in Canada on Thursday. Kudlow, a former CNBC contributor, was undergoing surgery for a hip replacement, according to three sources.

Lighthizer's opposition to the tariffs was earlier reported by The Wall Street Journal.

"Lighthizer is not happy," an unnamed administration official told the paper.

A White House spokesperson did not respond to a request for comment. Jeff Emerson, a USTR spokesperson, said Lighthizer supports Trump's strategy.

Peter Navarro, a White House economic advisor, told CNBC earlier Friday that Trump's threat of new tariffs came in response to Mexico's "export" of "illegal aliens."

"Look at what we are trying to do. This is actually a brilliant move by the president to get Mexico's attention, to get them to help us, because so far they have just been standing by," Navarro said.