Mr Medvedev said he had "taken into account the expression of free will by the Ossetian and Abkhaz peoples" and accused Georgia of failing over many years to negotiate a peaceful settlement.
"That was no easy choice to make, but it is the sole chance of saving people's lives," he added.
International dismay at Russia's declaration came almost immediately.
President Bush said Russia should "reconsider this irresponsible decision" and "live up to its international commitments".
"This decision is inconsistent with numerous United Nations Security Council resolutions that Russia has voted for in the past, and is also inconsistent with the French-brokered six-point ceasefire agreement which President Medvedev signed," he said in a statement.
"Russia's action only exacerbates tensions and complicates diplomatic negotiations," he added.
"In accordance with United Nations Security Council resolutions that remain in force, Abkhazia and South Ossetia are within the internationally recognised borders of Georgia, and they must remain so."
France, the current holder of the presidency of the European Union, also condemned Russia's decision and called for a political solution.
"We think it is against the territorial integrity of Georgia and we cannot accept it," Foreign Minister Bernard Kouchner said.
Nato's Secretary-General, Jaap de Hoop Scheffer, said the announcement was a "direct violation" of numerous UN Security Council resolutions on Georgia which Russia itself had endorsed.
Earlier, Russia cancelled a visit by Mr de Hoop Scheffer, one of a series of measures to suspend co-operation with the alliance.
Russia's ambassador to Nato said the trip would be delayed until relations between the two were clarified.
Georgia's President Mikhail Saakashvili accused Russia of trying to "break the Georgian state, undermine the fundamental values of Georgia, and to wipe Georgia from the map".
Georgian president speaks to BBC
"Today's step by Russia is completely illegal and will have no legal basis, neither for Georgia nor for the rest of the world," he said.
Mr Saakashvili described the declaration as "the first attempt in Europe after Nazi Germany and the Stalinist Soviet Union to... change the borders of Europe by force".
Speaking later to the BBC, he said the move had been "a blatant attempt to legalise the results of ethnic cleansing [which] Russian troops are continuing to commit, right now as we speak, and that have been committed during the last several years".
The president accused Russian troops of "throwing out the remaining population, destroying the villages, killing and raping and looting people" in the breakaway regions.
"This is 21st century brutal invasion, and 21st century large-scale ethnic cleansing," he said. "How can the world allow them to get away with this?"
Earlier, the head of European security organisation, the OSCE, Alexander Stubb, also accused Russia of "trying to empty" South Ossetia of Georgians.
The OSCE accused Russia of "trying to empty" South Ossetia of Georgians
Mr Saakashvili said the international community had to challenge "Russian aggression" in the strongest possible terms.
"This is not between Georgia and Russia anymore," he said. "This is an unparalleled challenge by Russia of international law and order."
He said the response required Western aid to help Georgia recover, an international peacekeeping force on the ground, and the speeding up of his country's integration of Nato.
In the South Ossetia and Abkhazia, however, Moscow's move was warmly welcomed.
The leader of South Ossetia's separatist government, Eduard Kokoity, said he would ask Moscow to set up a military base on his territory.
In the South Ossetian capital of Tskhinvali there were scenes of jubilation while residents in Abkhazia took to the streets to celebrate the news, firing into the air.
Cold War fears
In an interview with the BBC at his residency in Sochi, on the border with Abkhazia, Mr Medvedev later said Russia had been obliged to act following a "genocide" started by Georgian President Mikhail Saakashvili against separatists in South Ossetia in August.
The president compared Russia's recognition of Abkhazia and South Ossetia to the West's recognition of Kosovo, which unilaterally declared independence from Serbia in February 2008.
He also denied that Russia had breached the ceasefire agreement with Georgia, saying pursuing the security of the two regions included addressing their status.
"The most important thing was to prevent a humanitarian catastrophe to save the lives of people for whom we are responsible, because most of them they are Russian citizens," he said. "So we had to take a decision recognising the two states as independent."
Although most of Russia's forces pulled out of the rest of Georgia last Friday, it is maintaining a presence both within the two rebel regions and in buffer zones imposed round their boundaries.
Some Russian troops also continue to operate near the Black Sea port of Poti, south of Abkhazia, where Russia says it will carry out regular inspections of cargo.
The US said on Tuesday that its warships would deliver aid to Georgia's port of Poti, which is under Russian control. The move could mean US and Russian forces coming face to face.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.