SHANGHAI — As the United States challenges Europe, China, Canada, Mexico and much of the rest of the world over trade, deep factionalism within the Trump administration has flummoxed both American allies and rivals. The White House strikes a conciliatory tone one day and a militant one the next, often depending on which Trump advisers are in favor.

Increasingly, leaders in other countries are asking who is calling the shots: the globalists, the nationalists, the trade hawks or someone else?

To a degree, the mixed messages reflect the negotiating tactics of a president who likes to keep the other side off balance. Even while his team was in Beijing this weekend, President Trump, in a tweet, suggested a confrontational approach, calling out China over the trade imbalance. The two sides made little progress in discussions.

The inconsistency has spurred international leaders to court Trump officials who they think will offer a sympathetic ear, rather than the White House as a whole — a divide-and-conquer approach that could make trade deals harder to strike. It has also eroded the belief among many leaders that the Trump administration will keep its word.