Private security firm G4S has donated £2.5m to the armed forces after troops had to stand in for its absent staff at the Olympic Games.
The firm had a £284m contract to provide 10,400 staff for Olympic events but could not supply enough personnel.
Some 18,000 troops provided support at London 2012, including Army, Royal Navy and Royal Air Force staff, some of whom had their leave postponed.
G4S's donation will go to armed forces sports and welfare organisations.
The firm had previously described its failures as a "humiliating shambles" and was forced to apologise. Some 4,700 members of the armed forces had to stand in as a result of the company's shortfall.
The BBC's Ross Hawkins says that this payment does not replace the recompense pledged by the security firm to the police and the military.
G4S still intends to claim a management fee for its Olympic work, but expects to make a loss of between £35m and £50m.
A G4S spokesman said: "We wanted to recognise the huge contribution made by the military after it became clear that there would be shortfall in workforce delivery.
"After close consultation with the military it was decided that a substantial donation to a charity of their choice was the most appropriate response."
The BBC's home of 2012: Latest Olympic news, sport, culture, torch relay, video and audio
Defence Secretary Philip Hammond said the donation would "go some way" to recognising the extra work placed on the military because of G4S's shortcomings.
He added: "The armed forces provided more to the security and protection of the Games than had originally been planned, but as always they have carried out their tasks with professionalism and good humour.
"This contribution... is welcome news for the service welfare funds and will go some way to recognising the inconvenience and extra burden that this commitment has placed upon our forces and their families."
Chief of the Defence Staff General Sir David Richards said: "The armed forces are pleased to accept this donation.... It recognises all the hard work and commitment service personnel have displayed during the London 2012 Olympic Games.
"Together with G4S, the men and women of the Royal Navy, Army and Royal Air Force have delivered a safe and secure Olympics.
"I am glad that they are receiving the gratitude and recognition for the excellent work, not just from the public, but from those they are working alongside."
After the staff shortage became apparent, the head of security company G4S, Nick Buckles, told MPs he regretted it ever taking on the Olympic security contract.
He also said the company was no longer bidding for the security contracts for the next football World Cup and the next Olympics, both of which take place in Brazil.