A tweet Tuesday announcing a meeting between President Trump and Chinese President Xi Jinping sent stock markets soaring. (Qilai Shen/Bloomberg News)

President Trump said Tuesday morning that Chinese leader Xi Jinping had agreed to meet with him at the Group of 20 summit next week, a major development amid the ongoing trade war between two of the world’s largest economies.

Trump, in a Twitter post, wrote that he had spoken with Xi by telephone to confirm the meeting. Trump has said for days that he hoped to meet with Xi at the summit in Osaka, Japan, but Chinese officials had not yet confirmed the meeting would occur.

“Had a very good telephone conversation with President Xi of China,” Trump wrote on Twitter. “We will be having an extended meeting next week at the G-20 in Japan. Our respective teams will begin talks prior to our meeting.”

The Twitter post sent the U.S. stocks sharply higher, as investors had long worried that a protracted trade battle between the two nations could damage the U.S. economy and hurt numerous companies.

China’s Xinhua News, a state-run entity, wrote in a Twitter post following Trump’s announcement that the call came “at request” of the White House. And CCTV, a Chinese state broadcaster, quoted Xi as saying he is looking forward to the meeting.

“As the two largest economies in the world, China and the United States should play a leading role in promoting positive outcomes of the Osaka Summit of the Group of Twenty and injecting confidence and vitality into the global market,” Xi said, according to CCTV. “I would like to meet with Mr. President during the Osaka Summit of the leaders of the Group of Twenty to exchange views on fundamental issues related to the development of Sino-US relations.”

Trump has long alleged that the Chinese government rips off U.S. consumers and businesses through unfair trade practices, such as stealing intellectual property, luring away U.S. manufacturers, manipulating currency and subsidizing domestic companies in a way that makes it hard for U.S. firms to compete.

Last week, he insisted that China would eventually capitulate to his demands because of the economic damage his tariffs were inflicting on the country.

“China is going to make a deal, because they are going to have to make a deal,” Trump said during an interview with CNBC.

Trump has imposed tariffs on $250 billion in Chinese imports to the United States and threatened to impose tariffs on another $300 billion in goods if Xi refused to meet with him at the G-20 summit.

The two leaders last met in late 2018, at a G-20 summit in Argentina. At a dinner with top advisers, Trump and Xi agreed to negotiate to resolve the trade battle. But those talks broke down several weeks ago, when U.S. officials accused their Chinese counterparts of backtracking on several commitments.

Among other things, Trump has demanded that China purchase more U.S. goods and create restrictions on the theft of intellectual property. A number of Democrats have supported Trump’s tough tactics, but U.S. businesses have been alarmed that Trump has so far refused to cut a deal with Xi. This uncertainty has led a number of businesses to freeze investment as they wait to see whether the trade war will be resolved soon.

Trump made standing up to China a centerpiece of his 2016 presidential campaign, and he is set to announce his reelection campaign Tuesday night in Orlando.

Tariffs are a type of tax paid by U.S. companies when they import goods from another country. Those costs are often passed along to consumers in the form of higher prices. By making the foreign products more expensive, Trump has said the goal of tariffs is to push companies to move production to the United States.

Trump has used tariffs as a key tool in both economic and foreign policy. Two weeks ago, he threatened to impose a 10 percent tariff on all goods entering the United States from Mexico, but Mexico agreed to discuss new efforts to stem a surge of migrants at the border, and Trump indefinitely postponed the import penalties.

The tariffs on Chinese products are much steeper, however, affecting 25 percent of the $250 billion in goods. These tariffs apply to business equipment, furniture, computer products and a range of other materials. Hundreds of companies are in Washington this week petitioning the Trump administration for exemptions from future tariffs, as some have alleged their companies would be decimated if Trump follows through with his threat to impose tariffs on the remaining $300 billion in goods that hasn’t been penalized. A final decision on whether to impose those tariffs was expected to be made after the Osaka summit.

Trump said last week that he would move forward with those tariffs if Xi refused to meet at the G-20.

A number of Republicans have attacked the White House for relying on tariffs as a way to push foreign countries to change their behavior, alleging that he is effectively creating new taxes on U.S. businesses and consumers. But Trump has called himself “Tariff Man” and said he uses the tariffs as a way to exert leverage on foreign leaders to prompt concessions.

Chinese leaders have vowed to retaliate against Trump’s tariffs with penalties of their own against U.S. exporters. U.S. agriculture companies, particularly soybean farmers, have complained that they have been caught in the middle of the trade war and have seen Chinese purchases of their products plummet. To ameliorate the burden on farmers, many of whom come from states that will be key to Trump’s reelection, the White House has authorized billions of dollars in direct payments to offset the lost revenue.

Gerry Shih contributed to this report.