BALI, Indonesia - With international climate talks teetering toward collapse, countries rallied Saturday to a last-ditch agreement that would strive for a new global climate-change treaty over the next two years.

Consensus at a United Nations summit arrived after a day of high drama in which the United States drew boos for threatening to reject a deal and an angry Chinese delegation led a revolt by developing countries.

Last-minute compromise resulted in a so-called "Bali Road map'' -- a two-year plan to seek a treaty that would replace the Kyoto Protocol in 2012.

Delegates who had hoped to launch the talks with clear targets in hand were disappointed by a deal that eschewed mention of hard numbers and replaced them with fuzzy references to reducing greenhouse gases.

Canada helped gut some of the substance from Saturday's deal and then expressed regret when the final agreement was ultimately watered down even more than it had hoped.

But Environment Minister John Baird hailed the talks as a positive first step toward an effective global climate treaty.

"We were naturally disappointed in the language that weakened and watered down the agreement,'' Baird said.

"But it's better than no agreement.''

He said he was disappointed that the deal was almost completely stripped of any reference to numbers and targets that could have been the starting point for the discussion.

Canada sided with the U.S. and Japan in a small group of wealthy non-European countries that removed specific references to emissions targets for developed countries by 2020.

The treaty was also stripped of references to longer-term targets -- targets Baird said he had been prepared to accept.

But Baird said the Bali conference achieved its primary goals of launching negotiations, getting all countries to agree to basic parameters, and setting a 2009 deadline date.

Instead of clear targets Saturday's document said countries recognize that "deep cuts in global emissions'' will be required, and it called for a "long-term global goal for emissions reductions.''

Near-collapse

Even that mushy consensus came close to collapsing.

A Chinese negiotiator pounded his fist into a table and drew cheers from other developing countries when he angrily rejected an earlier draft amid complaints that poorer countries had been sidelined in 11th-hour discussions.

The talks then appeared doomed when the U.S. rejected a subsequent compromise.

But the chorus of boos that rained down on the American delegation was replaced by cheers when in a stunning about-face U.S. negotiator Paula Dobriansky declared she would accept the deal.

"We've listened very closely to many of our colleagues,'' she announced to a jubilant auditorium.

"We will go forward and join consensus.''

The hall erupted in an ovation for a U.S. delegation that had been cast throughout the summit as a climate culprit. Canada, Japan, and a small group of other countries were also frequent targets of criticism.

Liberal Leader Stephane Dion hailed the global agreement as an encouraging development in the fight against climate change. But he regretted the role played by Canada's government.

"If Canada would have shown more leadership it would have been better than that,'' he said.

"If Canada would have been with Europe instead of being in the same bed as President (George W.) Bush, it would have been better.''

Canada and its allies steadfastly rejected clear references in the main summit text to a goal for developed countries to reduce greenhouse gas emissions by 25 to 45 per cent from 1990 levels by 2020.

Baird said Canada could never reach that target.

He dismissed the European-sponsored objective as unattainable, arguing that Canada would need to slash emissions by 38 to 53 per cent within only 12 years to reach that target.

It's a position that earned Canada the scorn of environmentalists in Bali, with one spoof newspaper ad depicting Prime Minister Stephen Harper, Bush, and Japanese Prime Minister Yasuo Fukuda in a mock movie poster as stars on an environmental Titanic.

Environmentalists said they were pleased a deal had been salvaged. But they continued to question the role Canada played in Bali. Steven Guilbeault of Equiterre said the Canadian delegation showed no leadership at the summit -- with regrettable consequences.

"We could have had a historic agreement here in Bali,'' he said.

"We have to go home with a watered-down agreement.''

The UN chief on climate change, Yvo de Boer, hailed the deal as a collapse of the "Berlin Wall'' between countries committed to fighting global warming and those content to sit on the sidelines.

Gov't vs. environmentalists

But that spirit of collaboration did not ease a bitter dispute between the Canadian government and its own country's environmentalists, who engaged in open warfare throughout the summit.

Baird refused to meet with green groups in Bali and his delegation worked actively to discredit them.

Government officials drew attention to some having partisan ties to the Liberal party. They also planted suggestions in journalists' ears that green groups contributed to global warming by arriving at Bali in such large numbers on greenhouse-gas-spewing airplanes.

The environmentalists swung back repeatedly.

Their tactics ranged from conventional means like petitions, to more covert efforts like putting Canadian media in touch with foreign diplomats who criticized their country's performance.

They even tried sleep-deprivation tactics with one Canadian official. The cellphone number of an aide to Harper was plastered on the Internet, and he was bombarded with hundreds of crank-calls and text messages throughout the wee hours Saturday.

Green groups also put Baird on the defensive by informing Canadian media any time the minister left a meeting. He found himself fending off suggestions that he skipped critical talks late Thursday.

Saturday's developments came after marathon negotiations overnight, which first settled a battle between Europe and the U.S. over whether the document should mention specific goals for rich countries' obligations to cut greenhouse gas emissions.

Upcoming talks may help determine for years to come how well the world can control climate change, and how severe the consequences of global warming will be.

In a separate agreement among Kyoto signatories, Baird was among the few voices calling for the 2020 targets to be removed.

A dozen countries then rose to take a slap at Canada's position and Baird eventually agreed to leave the target in the final text -- even though he repeated later that Canada can never meet it.

As for developing countries, the final document instructs negotiators to consider incentives and other means to encourage poorer countries to curb, on a voluntary basis, growth in their emissions.

The explosive growth of greenhouse emissions in China, India and other developing countries could negate any cutbacks in the developed world.

The Bali conference had been charged with launching negotiations for a regime of deeper emissions reductions to succeed the Kyoto deal, which requires 37 industrial countries to cut output of carbon dioxide and other greenhouse gases by five per cent below 1990 levels by 2012.

Earlier, UN Secretary General Ban Ki-moon had expressed frustration over the last-minute dispute over the Bali document and urged more than 180 national delegations to swiftly adopt it.

The U.S. has come under intense criticism in Bali, including from former  vice-president Al Gore, over the Bush administration's opposition to mandatory emission cuts.

But all parties acknowledged that negotiations cannot succeed without the involvement of the United States, the world's worst emitter of greenhouse gases.

For years, the rest of the world has sought to bring the Americans into the framework of international mandates. At this point, however, many seem resigned to waiting for a change in White House leadership after next November's election.

In a series of landmark reports this year, the UN's network of climate scientists warned of severe consequences -- from rising seas, droughts, severe weather, species extinction and other effects -- without sharp cutbacks in emissions of the industrial, transportation and agricultural gases blamed for warming.

To avoid the worst, the Nobel Prize-winning panel said, emissions should be reduced by 25 per cent to 40 per cent below 1990 levels by 2020.

The Kyoto signatories have accepted that goal, and the numbers were written into early versions of the Bali conference's draft decision statement -- not as a binding target, but as a suggestion in the document's preamble.