By Sarah Marsh

HAVANA (Reuters) - Japanese Prime Minister Shinzo Abe said on Friday that his visit to Communist-ruled Cuba, the first ever by a Japanese leader, had turned a new page in bilateral relations and the two countries would now deepen their economic relationship.

Abe, who met on Thursday with Cuban President Raul Castro and his predecessor and older brother Fidel Castro, said the issue of unpaid debt had long constrained this relationship.

Yet this was no longer an obstacle, he told a news conference in Havana, as the two countries had agreed on a plan to reorganize that debt. Some will become financing for development projects that could involve Japanese companies.

"This visit has turned a new page in 400 years of Japan-Cuba friendship," Abe said. "I met with Raul Castro and agreed to intensify our economic cooperation".

Many of Cuba's long-term trading partners are using debt forgiveness, swaps and new financing to try to win investment opportunities on the island ahead of their U.S. competitors in the wake of the detente between Havana and Washington.

"Cuba is an extremely attractive investment destination for Japan," Abe said. "As the U.S. has eased sanctions, Cuba has made efforts to improve its investment environment."

"I believe that this will prompt both trade and investment by Japanese firms," he added.

Cuba boasts a highly educated workforce, security and a strategic geographic position, he said. There was also a "huge demand for infrastructure" on the Caribbean island that could become a hub between Asia, the Americas and Europe.

Trading house Mitsubishi Corp told Reuters in July it was scouting for infrastructure projects at Cuba's Mariel special development zone, which stands to benefit from increased traffic through the renovated Panama Canal.

Abe said the Japan International Cooperation Agency (JICA) would also be establishing a permanent office in Cuba and Japan would be donating 1.27 billion yen ($12.58 million) of medical equipment to the country.

The Japanese leader said he had agreed with Raul Castro to cooperate on various challenges in the international community, and had raised the issue of North Korea's nuclear program.

Cuba is one of North Korea's few diplomatic allies, along with China, and a fellow member of the non-aligned movement formed in 1961 by states wanting to avoid siding with the United States or the Soviet Union.

"The international community has to respond in a united way to this new stage of threat which is a blatant provocation by North Korea," Abe said, adding that the Chinese role was "extremely important".

"With North Korea there is no point in having dialogue for the sake of dialogue alone. We need to apply tough pressure to North Korea," he said.

The words Fidel Castro wrote in the guestbook at Hiroshima's site of the world's first atomic bombing when he visited in 2003, "May such barbarity never happen again”, were deeply engrained in the hearts of the Japanese, Abe said.

The prime minister had also expressed his gratitude to Raul Castro for Cuba's support for Japan's candidature as permanent member of UN Security Council, his office said.

Abe's visit to Cuba is one of a slew by Western leaders since it began normalizing ties with the United States nearly two years ago. However, it is unusual for a Western leader to meet Fidel Castro, who usually only sees close allies. U.S. President Barack Obama visited Cuba in March and met with Raul but not Fidel Castro.

(Reporting by Sarah Marsh in Havana and Elaine Lies in Tokyo; Editing by William Mallard and Chizu Nomiyama)