TORONTO – President Obama on Sunday welcomed an international commitment for rich countries to slash their deficits in half by 2013, despite his earlier warnings against halting stimulus spending too abruptly.

“We can’t all rush to the exits at the same time,” Obama told a news conference at the conclusion of a summit of the 20 major industrial and developing economies.

Obama also issued a warning to North Korea, saying its alleged sinking of a South Korean warship was “belligerent behavior that is unacceptable” to the international community.

“It is absolutely critical for the international community to rally behind” South Korean President Lee Myung-bak, Obama said.

Obama spoke after G-20 leaders issued a statement calling for “advanced” nations to cut their budget deficits — as a proportion of gross domestic product growth — in half by 2013, and to put their annual deficits on either a lower or more stable basis by 2016.

Despite his warnings against slamming on the stimulus brakes too soon, Obama said the final summit communique was in sync with his own views that deficit reduction was important for the midterm and long term. But in the short run, he said, it is important to maintain stimulus spending in those countries that can afford it.

“Some countries, Greece being the most obvious example, have to act immediately” to lessen the risk of defaulting on their debt obligations, Obama said. But other countries have to decide how much flexibility they have to both encourage growth and job creation without going too much deeper into debt.

“The point is, in each country, what we have to recognize is that the recovery is still fragile,” Obama said.

But if financial markets are skittish and don’t have confidence in a country’s fiscal soundness, “then that is also going to undermine our recovery.”

Asked about a five-year Afghanistan exit strategy endorsed Saturday by the Group of Eight major industrial democracies, Obama cited “an obsession about when do we leave.”

He said there remains “a vital national interest that Afghanistan not be used as a base to launch terrorist attacks.” He would not commit to a firm timetable for U.S. withdrawal.

Obama said it’s not a simple choice between getting up and leaving immediately or staying indefinitely.

He said the United States will not “suddenly turn off the lights and let the door close behind us.”