BEIJING/WASHINGTON (Reuters) - The leaders of the United States and China on Friday both underscored their desire to sign an initial trade deal and defuse a 16-month tariff war that has lowered global growth, providing a welcome boost to financial markets.

Chinese President Xi Jinping, in rare comments on the trade tensions with Washington, said Beijing wants to work out an interim or ‘phase one’ trade pact, but is not afraid to retaliate when necessary.

Hours later, U.S. President Donald Trump said a trade accord with China is “potentially very close,” although he insisted that any deal would have to be weighted to favor the United States after years of trade imbalances with China.

Speaking on Fox New Channel’s “Fox & Friends,” Trump also urged China and Hong Kong to calm the situation in Hong Kong, wracked by months of pro-democracy protests, calling it a complicating factor in the trade talks.

The S&P 500 and Dow Jones indexes eked out gains on Friday after the comments by Trump and Xi, reversing losses triggered earlier in the week by reports that a truce could slip into next year.

Economists say the prolonged dispute between the world’s two largest economies is lowering global growth, disrupting supply chains, curtailing investment and curbing business confidence.

“We want to work for a ‘phase one’ agreement on the basis of mutual respect and equality,” Xi told representatives of the New Economy Forum organized by Bloomberg LP, according to a pool report.

“When necessary we will fight back, but we have been working actively to try not to have a trade war. We did not initiate this trade war and this is not something we want.”

Global financial markets retreated this week on fresh fears that the trade talks could flounder, unnerved by reports that Trump could sign into law two bills backing protesters in the Chinese-ruled city of Hong Kong.

FILE PHOTO: Containers are seen at the Yangshan Deep Water Port in Shanghai, China August 6, 2019. REUTERS/Aly Song

Trump did not make clear his intentions during the Fox News interview, saying, “We have to stand with Hong Kong but I’m also standing with President Xi.”

Concerns of a broader deterioration in Sino-U.S. ties weighed on markets this week. U.S. Navy warships twice sailed near islands claimed by China in the South China Sea in recent days, angering Beijing.

Completion of a phase one trade deal could slide into next year, trade experts and people close to the White House have told Reuters, with Beijing asking for more extensive tariff rollbacks and Washington countering with increased demands of its own.

Trump said he was troubled by Xi’s insistence on “equality,” countering that the United States had suffered for years due to large Chinese trade surpluses.

“I told President Xi, ‘This can’t be like an even deal. We’re starting off from the floor and you’re already at the ceiling,’” Trump said in the Fox News interview.

China’s official Xinhua news agency quoted Xi as saying ties between Washington and Beijing were at a pivotal moment.

“Both the United States and China should strengthen their communication over strategic issues and avoid misunderstanding and misjudgment,” it quoted Xi as saying during a meeting with former U.S. Secretary of State Henry Kissinger in Beijing.

MORE TRADE TALKS?

China has invited top U.S. trade negotiators for a new round of face-to-face talks in Beijing, the Wall Street Journal said, citing unnamed sources. It added that Beijing hoped the talks could take place before next Thursday’s U.S. Thanksgiving holiday.

U.S. officials have indicated willingness to meet but have not committed to a date, it added, and they would be reluctant to travel for the discussions unless China made clear that it would make commitments on intellectual property protection, forced technology transfers and agricultural purchases.

Trump told reporters at the White House the U.S.-China trade deal was coming along well, adding, “The question is whether or not I want to make it.”

Former U.S. Trade Representative Charlene Barshefsky said she assumed China would insist on some tariff relief in the phase one deal.

“Otherwise, this is an entirely one-sided exercise, and I’ve never known the Chinese to negotiate one-sided deals to their disadvantage,” she said at a group interview on the sidelines of the Bloomberg forum.

Officials from Beijing had suggested Xi and Trump might sign a deal before Dec. 15, when U.S. tariffs on about $156 billion in Chinese goods are set to take effect, including holiday gift items such as electronics and Christmas decorations.

In Beijing on Wednesday, Vice Premier Liu He, China’s chief negotiator in the trade talks, said he was cautiously optimistic on a phase one deal, Bloomberg News said, citing people who attended a dinner event ahead of the forum.

“The two countries should really ink the deal the sooner the better, at least a truce, and that will inject some certainty into the market and the economy,” Hu said.

“Based on this, we can clear out a consensus on complicated structural problems, and strive for a comprehensive final agreement.”