The midfielder was part of the Gillingham side relegated to League Two on the final day of last season.
However, following his subsequent Priestfield Stadium departure, he has today joined the Posh on a two-year deal with an option.
Pompey fans have long harboured hopes of the 26-year-old returning to Fratton Park following a successful loan spell in 2018-19.
Thompson netted three times in 27 outings for Kenny Jackett’s side, with his Millwall recall coinciding with the Blues surrendering top spot of League One.
They ultimately finished fourth following his January 2019 exit, while lost to Sunderland in the play-off semi-finals.
Thompson told Peterborough’s official website: ‘It has been a bit of a whirlwind the past few weeks.
‘It has been great to talk to the people at the club and it is something that I wanted to be a part of. I can’t wait to get started.
‘I know a few of the lads already, I was with Nathan Thompson at Portsmouth and I know Sammie Szmodics and Mark Beevers and have played against a lot of the other lads.
‘I like to think that I am an all-action midfielder. I really enjoyed my time at Millwall, I had some really good times there and it was great to get games under my belt at Gillingham in the second half of last season.
‘It was important to get everything sorted before pre-season and now I can come back and am raring to go.’
Thompson made 17 appearances for Gillingham last term, netting once.
He faced Pompey at Fratton Park in April, when the Blues recorded a 3-1 success to dent the Gills’ hopes of remaining in League One.
The ex-Millwall man’s short-term deal expired at the season’s end, enabling him to join Peterborough on a free transfer following their relegation from the Championship.
A message from the Editor, Mark Waldron
You can support our local team of expert Pompey writers by subscribing here for all the latest news from Fratton Park for 9p a day, thanks to our 30%-off transfer window deal.