Rules which denied about 4,000 war widows and widowers a military pension are to be changed next year.
From April 2015, those who "remarry, cohabit or form a civil partnership" would be entitled to the pension for life, the Ministry of Defence said.
Under current rules some have to surrender their survivor's pension.
Irene Wills, chair of the War Widows' Association, said Prime Minister David Cameron had apologised for the delay in implementing the change.
She said: "Mr Cameron said he is sorry we had to wait so long, but he realised that it was a mistake and he is very pleased to now right that mistake and allow all widows to keep their pensions."
She met Mr Cameron on Saturday to deliver a thank you letter.
Defence Secretary Michael Fallon said he was putting right an issue that had caused "upset and disappointment for many years".
By Jonathan Beale, BBC defence correspondent
The government's U-turn is timely. The War Widows' Association had been due to hand in a petition to Downing Street against what it calls an injustice this morning, before they hold their annual Remembrance Service at the Cenotaph in Whitehall.
Now they say they'll be sending the prime minister a thank you letter instead. Around 4,000 people - mostly widows - will benefit from the changes. They are those who lost loved ones serving between 1973 and 2005 - women whose partners died or were killed during the Troubles in Northern Ireland, or the wars in the Falklands and Iraq.
The cost of service pensions to those who remarry or find new partners will be about £120m over the next 40 years - a small price to pay for putting right an anomaly ministers now recognise has caused "upset and disappointment for years".
The charity said that under the current system, some of those whose spouses died or left military service between April 1973 and April 2005 stopped receiving their survivor's pension once they remarried, cohabited with a new partner or formed a civil partnership.
But those whose spouse died or left military service before 1973, and those who were widowed after 2005, kept their survivor's pension through other schemes.
The association said this meant some widows and widowers were effectively left "disadvantaged" because of the date their spouse died, calling it the "wrong time to die".
As of 1 April next year, those who already receive a survivor's pension will be allowed to keep their pension for life if they do remarry, cohabit or form a civil partnership.
War Widows' Association chairman Irene Willis said: "After campaigning for this amendment, which will benefit a small number of war widows whose partners died in service to their country, we are delighted that the government has decided to provide pensions for life."
Janice Nicoll's husband Andrew was a lieutenant commander in the Royal Navy. He died in 2006.
She subsequently met somebody else but says she cancelled their wedding, fearing she would lose her pension.
"It's absolutely wonderful news for myself, my children and my fiancée.
"It means we can actually rebuild our lives and provide a secure family home for my children which has been so disjointed.
"After Andrew died, it left such a hole in our lives and it's just fantastic I can actually do that now financially secure.
"I've got two children at university and two at senior school and, financially, it just wasn't worth risking the children's security by risking that part of my pension."
'Fair and just'
Maj Gen John Moore-Bick, general secretary of the Forces Pensions Society, told BBC Breakfast: "One of the aspects of armed forces service in the past, in the present and in the future is a degree of turbulence.
"If you move house 10, 15, 20 times as a military spouse, you haven't any chance of building up any sort of pension entitlement."
He added: "To make this ruling is only fair and just and I'm very pleased the prime minister has done it."
Veterans' minister Anna Soubry told BBC Breakfast it was "the right time to do it".
She said: "The money is not actually very much in the overall scheme of things, it's the principle that's important and it's important that we've done it under the covenant.
"I think that's the first time anything like this has been done under the covenant and it shows the power of it."
The Armed Forces Covenant states that personnel and veterans as well as their families should be "sustained and rewarded" for their service.
Labour said it had pressed the government to "address this anomaly". Shadow defence secretary Vernon Coaker said he was "glad it has now been resolved".
The change will coincide with the launch of the new armed forces pension scheme, the MoD added.