Earlier, the US and France called the Russian move regrettable, while the UK said it categorically rejected it. Nato said the declaration violated numerous UN Security Council resolutions that Russia itself had endorsed.
However the leaders of Abkhazia and South Ossetia, which have had de facto independence since the early 1990s, thanked Russia.
Fighting between Russia and Georgia began on 7 August after the Georgian military tried to retake South Ossetia by force.
Russian forces subsequently launched a counter-attack and the conflict ended with the ejection of Georgian troops from both South Ossetia and Abkhazia and an EU-brokered ceasefire.
'No easy choice'
In an announcement on Russian state television, President Medvedev said he had signed a decree to recognise Abkhazia and South Ossetia as independent states.
He instructed the Russian foreign ministry to open negotiations on formal diplomatic relations with the two regions and called on other states to follow his country's example.
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 to the problem.
Many South Ossetians feel closer to Russia than Georgia
"That was no easy choice to make, but it is the sole chance of saving people's lives," he added.
The move followed votes in both houses of parliament on Monday, which called on Moscow to recognise the regions' independence.
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 his Georgian counterpart against separatists in South Ossetia.
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."
Mr Medvedev said relations with the West were deteriorating sharply and that a new Cold War could not be excluded, but that Russia did not want one.
"There are no winners in a Cold War," he said.
Later, Georgia's President Saakashvili accused Russia of trying to "break the Georgian state, undermine the fundamental values of Georgia and to wipe Georgia from the map".
"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.
"Russia has made an extraordinary strategic mistake and has badly damaged its place in modern international relations."
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".
Western countries, including the US, Germany, the UK and France also condemned Russia's move.
US Secretary of State Condoleezza Rice, speaking from the West Bank city of Ramallah, said the decision was "regrettable".
"Since the United States is a permanent member of the Security Council this simply will be dead on arrival in the Security Council," she said.
Late on Monday, the US state department had warned that recognition of the two provinces' independence would be "a violation of Georgian territorial integrity" and "inconsistent with international law".
In a statement, it said President George W Bush had called on Russia's leadership to "meet its commitments and not recognise these separatist regions".
In the two breakaway regions, 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.
"We feel happy," said Aida Gabaz, a 38-year-old lawyer in the Abkhaz capital Sukhumi.
"We all have tears in our eyes. We feel pride for our people."
Earlier on Tuesday, Russia cancelled a visit by Nato's secretary general, one of a series of measures to suspend co-operation with the military alliance.
In Abkhazia, hundreds danced and embraced near a government building
Russia's ambassador to Nato said the trip would be delayed until relations between the two were clarified.
Dmitry Rogozin said a "new understanding" needed to be reached between Russia and Nato.
The BBC's Humphrey Hawksley, in Moscow, says the recognition is bound to dramatically heighten tensions in Russia's already fragile relationship with the West.
He says this and a series of other announcements indicate that Russia is preparing itself for a showdown.
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.
Earlier, the head of European security organisation, the OSCE, Alexander Stubb, accused Russia of trying to empty South Ossetia of Georgians.
Speaking to the BBC's Europe Today programme, he said: "They are clearly trying to empty southern Ossetia from Georgians, which I don't think goes by any of the books that we deal with in international relations".
At a checkpoint in South Ossetia, the BBC's Gabriel Gatehouse said a South Ossetian commander said many Georgian civilians had already left of their own accord, because they were scared of the guns.
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.