President Trump and Japanese Prime Minister Shinzo Abe agreed Wednesday to begin direct trade negotiations, in a move that could reshape two of the world’s largest auto industries and offer American farmers better access to Japanese consumers.

Japan had resisted bilateral talks with the United States for nearly two years, preferring that its closest ally return to the 12-nation Trans-Pacific Partnership, a trade deal that Trump quit in one of his first acts as president.

Wednesday’s decision followed Trump’s announcement this summer that he was considering imposing tariffs on imported automobiles, including from Japan.

Negotiations will begin soon on a deal that would fall short of the comprehensive free-trade agreement that Trump had initially promised, governing goods trade and some services transactions, according to a joint statement by the two governments.

The United States and Japan also said they would work together — and with the European Union — to curb unfair trading practices by China.

“I think it will be something very exciting,” Trump said in New York, where he was attending the United Nations General Assembly. “It can only be better for the United States . . . I think it’s going to be better, really, for both countries.”

The United States said it agreed to “refrain from taking measures against the spirit’’ of the joint statement, an indication that Trump will hold off on imposing auto tariffs until the talks run their course.

The president made a similar deal with the European Union in July, agreeing to defer any auto tariffs while talks proceed. The Commerce Department is not expected for several months to complete a study that is required before the president can impose the tariffs.

U.S. Trade Representative Robert E. Lighthizer is scheduled to brief lawmakers Thursday on the administration’s trade policies, including a request for negotiating authority to pursue a deal with Japan.

The Japan talks will proceed in two phases: a blitz to reap quick gains, followed by a second set of negotiations on additional, unspecified “trade and investment items,” the statement said.

U.S. automakers have struggled to gain a foothold in Japan. Ford Motor Co. pulled out of the country in 2016 after years of dismal results, citing Japanese import barriers. Last year, the United States exported just $2.2 billion worth of autos and auto parts — less than in 2012 — while importing more than $55 billion of Japanese vehicles and components, according to the Commerce Department.

“The history of U.S. efforts to open the Japanese market to U.S. car exports is one that is utterly littered with failure,” said Edward Alden, a trade expert at the Council on Foreign Relations.

The American Automotive Policy Council, representing Detroit’s Big Three carmakers, said any deal should result in “truly reciprocal market access” and eliminate regulations that inhibit sales of foreign cars in Japan.

The United States and Japan are approaching the negotiations with different objectives in mind. The Trump administration wants American carmakers to enjoy better access to the Japanese market “to increase production and jobs in the United States.”

Abe’s government said it would offer American farmers the same benefits they had won in the TPP agreement that Trump quit but no better terms, according to the joint statement.

Today, farmers from countries in the renamed Comprehensive and Progressive Agreement for Trans-Pacific Partnership enjoy much lower Japanese tariffs than their American competitors. So a new U.S.-Japan accord will be aimed at eliminating that disadvantage and regaining the benefits that the United States lost by leaving the TPP.

“The U.S. agricultural community must be breathing a sigh of relief, particularly in light of the hardships farmers are experiencing with the China tariffs,” Wendy Cutler, who negotiated the Pacific trade deal for the Obama administration, said via email. “Japan is now offering the U.S. agriculture market access in line with what it has already given to the ten other TPP countries, as well as to the E.U.”

Lighthizer, without providing specifics, said there would be “an awful lot of differences between what was negotiated in TPP and the kind of agreement we expect with Japan.”

One of Trump’s main objectives is narrowing the persistent gap between the amount of goods that the United States buys from Japan and its lower volume of sales to Japanese customers.

The United States incurred a $70 billion deficit on its goods trade with Japan last year, which the president says is a mark of unfair trade that is weakening the American economy. Few mainstream economists regard bilateral trade gaps as significant.

In April 2017, the two countries began an economic dialogue headed by Vice President Pence and Deputy Prime Minister Taro Aso, which has produced few tangible results.