Three of the bodyguards have since been confirmed dead and Alan McMenemy, the fourth guard, is also believed to have been killed.
Gordon Brown, the British prime minister, said: "I am hugely relieved by the wonderful news that Peter has been freed, and will be reunited with his family as quickly as possible.
"They have faced a terrible ordeal, and I know that the whole nation will share their joy that he is coming home. I pay tribute to all those who helped in the protracted effort to secure the release."
"At this moment of celebration, we also remember the families of British hostages who have been killed in Iraq and elsewhere.
"And we pledge to continue to do everything we can to bring British hostages back to their loved ones, including the remaining hostage of the group in Iraq, Alan McMenemy. I demand that the hostage takers return him to us."
Miliband said the release of Moore had been secured following a process of political reconciliation driven by the Iraqi government.
"For many months now, the government of Iraq has been taking forward a process of national reconciliation with armed groups prepared to renounce violence," he said.
"That process of reconciliation has made possible Peter Moore's release today.
"I hope it will lead also to the end of the scourge of hostage-taking and violence."
Terry Waite, a Briton who was held hostage in Lebanon for several years, told Al Jazeera: "When you do come out of a situation like that it is a confusing situation.
"When you are held captive you don't know if you are going to live to see the end of the day. And suddenly you come out and you're free."
The bodies of three of the bodyguards were returned to the UK earlier this year.
The Guardian newspaper reported that the capture of the five men was masterminded by Iran's Revolutionary Guard.
A former unnamed Revolutionary Guard was quoted saying they were taken across the Iranian border and held in two camps, including one called Qasser Shiereen.
"It was an Iranian kidnap, led by the Revolutionary Guard, carried out by the al-Quds Brigade," he was quoted as saying.
"My contact works for al-Quds. He took part in the planning of the kidnap and he watched the kidnapping as it was taking place. He told me that they spent two days at the Qasser Shiereen camp.
"They then took them deep inside Iran."
According to the paper, Moore was targeted because he was installing a computer tracking system that would show how vast amounts of international aid money from Iraqi institutions was diverted to Iranian militia groups in Iraq.
The foreign office told the Guardian: "We have no evidence that the British hostages, including Peter Moore, were held in Iran."