The 22-year-old has been on loan at Posh since mid-November and has scored five goals in six games for Darren Ferguson's side.
A deal will now become permanent on January 2, with the fee potentially rising to £750,000.
Ferguson told the club's official website: "Dwight has done very well and him and Lee Tomlin have formed an effective partnership, they have caused a lot of problems and long may that continue.
"I am pleased that everything has been sorted out and credit to the chairman for providing the finance for the deal."
Gayle added: "I am delighted that everything went well, I have really enjoyed my time at the club during my loan spell and I am very pleased to be staying. I want to improve and I believe I can do that here."
Gayle, in his first season in professional football, has certainly proved himself a force to be reckoned with, having scored seven goals for the Daggers in 20 appearances before his move to London Road.
- Sports & Recreation
- Darren Ferguson