He has been signed initially on loan but the move should be made permanent before transfer deadline day on Thursday of this week.
Williams was signed on a free transfer by Posh manager Barry Fry from West Ham in June 2001.
He had been at The Hammers from aged 14 and had progressed to the reserve team at Upton Park.
He has made 42 appearances for Peterborough this season scoring two goals.
Williams goes straight into the squad to face Bradford on Tuesday night.