The 26-year-old was a Scottish Cup winner with the McDiarmid Park side before moving to Sheffield Wednesday in summer 2014 and Preston a year later.
Saints boss Tommy Wright told the club website: "I'm delighted that we got the deal done - the chairman worked so hard to resurrect the move. It's no secret that he was the man I wanted to bring back to the club so it's really exciting to be working with him again.”