The donation follows G4S’s failure to train and deploy enough Olympic security staff, forcing more than 4,700 members of the armed forces to be put on standby for the Games.
The private security firm was forced to apologise after failing to meet its £284m contract to provide a total of 10,400 staff for the Games.
Two weeks before the opening ceremony it emerged that G4S had not trained or deployed enough security staff and the army was called in to fill the gap.
In total, 18,000 personnel provided support at London 2012, including army, Royal Navy and Royal Air Force staff.
Defence Secretary Philip Hammond said the donation would “go some way” to recognising the burden placed on the armed forces by the security shambles.
“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,” he said.
“This contribution from G4S 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.”
Read more: The anatomy of the G4S shambles
The £2.5m donation will go towards welfare amenities including sports equipment and to sports associations which have backed serving athletes, including rowing gold medallists Captain Heather Stanning and Lieutenant Pete Reed.
Chief of the Defence Staff General Sir David Richards said: “The armed forces are pleased to accept this donation from G4S. It recognises all the hard work and commitment service personnel have displayed during the London 2012 Olympic Games.
“It recognises all the hard work and commitment service personnel have displayed during the London 2012 Olympic Games.
General Sir Nick Parker, standing joint commander for operation Olympics, paid tribute to G4S staff and volunteers.
“Working side by side I believe they are doing a very professional job in providing Olympic security,” he added.