* Obama reaffirms commitment to defend Japan
* Two-sides fall short of trade deal, despite lengthy talks
* China unhappy at comments on disputed islands
* U.S. President flies on to South Korea for second stop on Asia tour (Adds China lodging complaints with U.S., Japan embassies)
By Linda Sieg and Matt Spetalnick
TOKYO, April 25 (Reuters) - U.S. President Barack Obama wrapped up a state visit to Japan on Friday during which he assured America's ally that Washington would come to its defence, but failed to clinch a trade deal key to both his "pivot" to Asia and Prime Minister Shinzo Abe's economic reforms.
Obama and Abe had been seeking to show that the alliance was strong in the face of a rising China. But their success in putting recent strains behind them was partly marred by a failure to reach a deal seen as crucial to a broader regional trade pact.
That failure delayed a joint statement on security and economic ties until shortly before the U.S. leader left for Seoul, the next stop on his week-long, four-nation Asian tour.
Obama and Abe had ordered their top aides to make a final push to reach a trade agreement after the leaders met on Thursday, but Economy Minister Akira Amari told reporters that gaps remained despite recent progress.
"This time we can't say there's a basic agreement," Amari told reporters after a second day of almost around-the-clock talks failed to settle differences over farm products and cars. "Overall, the gaps are steadily narrowing."
Putting a positive spin on the trade front, the two sides said in their statement that they were committed to taking "bold steps" to reach a two-way deal, which would inject momentum into a delayed 12-nation Trans-Pacific Partnership (TPP) trade pact.
A senior U.S. trade official said the two sides had achieved a breakthrough on market access, but provided few details.
"There are still details to be worked out. There is still much work to be done ... We believe we do have a breakthrough in our bilateral negotiations," said the senior official accompanying Obama to South Korea.
The TPP is high on Abe's economic reform agenda and central to Obama's policy of expanding the U.S. presence in Asia.
Obama on Thursday assured Japan that Washington was committed to coming to its defence, including of tiny isles at the heart of a row with China, but denied he had drawn any new "red line" and urged peaceful dialogue over the dispute.
Friday's joint statement echoed those comments and put in writing a long-held U.S. stance that the uninhabited islands in the East China Sea are covered by a security treaty that obliges the United States to defend Japan, where it has a number of military bases.
Those comments drew a swift rebuke from Beijing, which also claims sovereignty over the Japanese-controlled islands, known as the Senkaku in Japan and the Diaoyu in China. Japanese and Chinese patrol ships have been playing cat-and-mouse near the islands, and Washington is wary of being drawn into any clash.
China's Foreign Ministry said in a statement late on Friday that it has lodged complaints with the U.S. and Japanese ambassadors in Beijing over the joint statement.
"We urge the United States and Japan to abandon their Cold War mentality, and respect the concerns and interests of other countries in the region, and avoid further interference with regional peace and stability," Foreign Ministry spokesman Qin Gang said at a separate daily news briefing.
The allies also said they wanted to build productive ties with China but expressed concern about its Air Defence Identification Zone covering the disputed isles, announced last year, as well as activities fanning tensions in the South China Sea, where other Asian countries have rows with Beijing.
"Our two countries oppose any attempt to assert territorial or maritime claims through the use of intimidation, coercion or force," the statement said.
The diplomatic challenge for Obama during his week-long, regional tour is to convince Asian partners that Washington is serious about its promised strategic pivot, without harming U.S. ties with China, the world's second-biggest economy. Beijing has painted the "pivot" as an effort to contain the rising Asian power.
Abe, who returned to office in 2012 pledging to boost Japan's security stance and tighten ties with the United States, hailed the joint statement as "historic" and said a "key milestone" had been reached in the trade talks.
A Japanese government official, however, told Reuters that the trade stalemate had delayed issuance of the broader statement until just before Obama's departure.
"They (the U.S. side) wanted to delay the statement until we finished TPP," a Japanese official said.
"Of course, TPP was not finished. It is still ongoing." But he added that there were some "meaningful discussions".
The senior U.S. official accompanying Obama said the two sides had "identified a pathway to market access" in the politically tricky agriculture and autos sectors.
Obama's three-day stay in Tokyo - the first full state visit by a U.S. president since 1996 - was meant to show that the U.S.-Japan alliance, the main pillar of America's security strategy in Asia, is solid at a time of rising tensions over growing Chinese assertiveness and North Korean nuclear threats.
But the trade squabbling risked leaving something of a bitter taste, despite the pomp and circumstance of a stay that included a formal dinner hosted by Emperor Akihito and a casual meal with Abe at an upscale sushi restaurant.
Asked about the summit, Finance Minister Taro Aso told a news conference that Obama did not have the clout to get consensus in the United States and that a deal was unlikely at least until after the U.S. mid-term Congressional elections in November. (Additional reporting by Elaine Lies, Antoni Slodkowski, Mark Felsenthal and Billy Mallard in TOKYO, and Michael Martina in BEIJING; Editing by Alex Richardson)