By Alister Doyle and Megan Rowling

MARRAKESH, Morocco (Reuters) - Nearly 200 nations agreed around midnight on Friday to work out the rules for a landmark 2015 global deal to tackle climate change within two years in a new sign of international support for a pact opposed by U.S. President-elect Donald Trump.

At the end of two-week talks on global warming in Marrakesh, which were extended an extra day, many nations appealed to Trump, who has called climate change a hoax, to reconsider his threat to tear up the Paris Agreement for cutting greenhouse gas emissions.

Showing determination to keep the Paris Agreement on track, the conference agreed to work out a rule book at the latest by December 2018.

A rule book is needed because the Paris Agreement left many details vague, such as how countries will report and monitor their national pledges to curb greenhouse gas emissions.

Two years may sounds like a long time, but it took four to work out detailed rules for the 1997 Kyoto Protocol, the Paris Agreement's predecessor, which obliged only developed countries to cut their emissions. Paris requires commitments by all.

The final text also urged rich nations to keep building towards a goal of providing $100 billion a year in climate finance for developing countries by 2020.

Moroccan Foreign Minister Salaheddine Mezouar told a news conference that Marrakesh had been the start of turning promises made in Paris into action.

"We will continue on the path," he said, urging Trump to join other nations in acting to limit emissions.

Fiji's Prime Minister Frank Bainimarama, who will host next year's climate meeting in Germany, invited Trump to drop his scepticism about climate change and visit the South Pacific nation to see the effects of stronger storms and rising seas.

Trump plans to favor fossil fuels over renewable energies and has threatened to halt any U.S. taxpayer funds for U.N. climate programmes.

On Thursday, governments reaffirmed their commitment to "full implementation" of the Paris accord which seeks to phase out greenhouse gas emissions this century and to limit a global average rise in temperature to "well below" 2 degrees Celsius (3.6 degrees Fahrenheit).

"Not one country has said that if President Trump pulls the United States out of Paris, they will follow him," said Alden Meyer of the Union of Concerned Scientists.

Environmental groups said the outcome in Marrakesh was a step in the right direction, but many issues needed to be resolved over the next two years, including funds for developing nations.

"Rich countries have been trying to wriggle out of their pledges to help poorer countries meet the costs of coping with impacts and greening their economies," said Harjeet Singh at ActionAid.

Also on Friday, a group of 48 developing countries most at risk from climate change said they would strive to make their energy production 100 percent renewable "as rapidly as possible", as part of efforts to limit global warming.

(Writing by Nina Chestney; Editing by Cynthia Osterman)