By Kiyoshi Takenaka and Chang-Ran Kim

OSAKA (Reuters) - Japanese Prime Minister Shinzo Abe and Chinese President Xi Jinping agreed to work together to promote "free and fair trade" in talks on Thursday that included a "complicated" global economic landscape, a Japanese official said.

Both countries are locked in a trade dispute with the United States as the world's biggest economy threatens its major trading partners with tariffs to reverse what President Donald Trump says are unfair imbalances that hurt the U.S. economy.

Meeting ahead of a two-day G20 summit in Osaka starting on Friday, Xi and Abe had a "very frank exchange", including issues between the United States and China, Japanese deputy chief cabinet secretary Yasutoshi Nishimura said. He declined to elaborate.

"The two leaders (Abe and Xi) agreed on developing a free and fair trading system," Nishimura told a briefing on the bilateral summit.

A major focus of the G20 gathering will be the outcome of a meeting between Trump and Xi scheduled on Saturday. Trump said on Wednesday that a trade deal with Xi was possible this weekend, but that he was prepared to impose tariffs on virtually all Chinese imports if disagreement persisted.

Abe and Xi agreed to continue to work toward creating multilateral free-trade pacts, including RCEP (Regional Comprehensive Economic Partnership) and a trilateral Japan-China-South Korea free trade agreement, Nishimura said.

Japan and China, along with the 10-nation Association of South East Asian Nations (ASEAN), Australia, India, New Zealand and South Korea are aiming to conclude negotiations for the RCEP free-trade zone that would encompass nearly half of the world's population and a third of the global economy.

At the outset of their bilateral meeting, Abe said he hoped to improve ties further between Japan and China, inviting Xi as a state guest next spring. China has accepted the invitation, Nishimura said.

"Around the time of the cherry blossoms next spring, I would like to welcome President Xi as a state guest to Japan, and hope to further elevate ties between Japan and China to the next level," Abe told Xi earlier.

China-Japan ties have historically been strained by territorial disputes over a group of tiny East China Sea islets and the legacy of Japan's World War Two aggression.

But Tokyo and Beijing have sought to improve relations more recently, with Abe visiting Beijing in October last year when both countries pledged to forge closer ties and signed a broad range of agreements including a currency swap pact.

(Reporting by Kiyoshi Takenaka and Chang-Ran Kim; Editing by William Mallard and Jon Boyle)