The 34-year-old, who helped the Saints to their first Scottish Cup success last term against Dundee United, joined the club from Livingston in 2009.
But he concedes he was slightly apprehensive about the move.
“When I arrived, everyone was raving about how good Gary Irvine had been in the right-back position and I wondered if I had maybe made the wrong move,” he told the club’s official website.
“But I had confidence in my own ability and I’m delighted the way things have turned out.”
Mackay has made over 230 appearances for Tommy Wright’s men and becomes the latest player at McDiarmid Park to sign a new deal after Chris Millar, David Wotherspoon and Brian Easton all committed their futures to the club.
Wright said:“It’s great news for us and provides another piece in the jigsaw for next season already.
“Dave is as consistent as ever and although I know he sees himself moving into central defence eventually, Steven Anderson and Tam Scobbie are doing well in there at the moment so Dave might have to bide his time!”