TOKYO — When Shinzo Abe sat down for a three-hour dinner with President Trump at Trump Tower in New York in September, the pair celebrated the Japanese prime minister’s 64th birthday.

By the end of that week, it looked as if Mr. Abe was the one who had given Mr. Trump a gift.

Japan acquiesced to direct, two-way trade talks with the United States, dropping its two-year insistence on trying instead to hammer out a pact that included multiple countries. It gave crucial momentum to Mr. Trump’s campaign to redraw trade pacts with longstanding allies like Japan, Canada, Mexico and the European Union, even as he widens a trade war with China.

Japan won some prizes with the move, like forestalling threatened American auto tariffs. Still, holding on to those gains could be tough. The Trump administration has already indicated it may want more from Japan on autos and agriculture. And it has shown it won’t hesitate to turn up the heat when dealing with traditional allies, as it did when it demanded that Canada open its market to American dairy products.

The negotiations will be particularly delicate for Mr. Abe, who has spent a considerable amount of energy developing a personal relationship with Mr. Trump.