St Johnstone manager Callum Davidson praised his side for battling difficult conditions and an impressive Peterhead side to reach the last 16 of the Betfred Cup.
Saints prevailed in the winner-takes-all clash to finish top of their group above Dundee United, who are eliminated.
The Perth side were playing into a strong wind in the first half at Balmoor and emerged goalless before Stevie May won and converted two penalties in the first 15 minutes of the second period.
Chris Kane came off the bench to fire home the third before Shaun Rooney's own goal made the final score 3-1.
Davidson told Saints TV: "It's a tough place to come and it was tough conditions. But I thought the boys applied themselves really well.
"We always knew it was going to be a tough game first half. It was actually harder playing downwind than into the wind. But they adapted and we started to control the game once we got that first goal.
"All credit to Peterhead, they knocked the ball around well. They have some good players, good composure on the ball, and they made it very difficult for us."