Preston fans were fearing a repeat of last season's collapse in the run-in when they won just one of their final 15 games to stay up on the last day.
This massive victory, just their second in 13 league games, will settle nerves and Lewis Dobbin stood out with Devine.
Preston, who were missing the suspended Jordan Thompson, began brightly, but it was Stoke who took the lead after just four minutes thanks to a moment of magic from Thomas for his 10th goal of his fine season.
Preston gave the ball away and Junior Tchamadeu burst forward down the right before crossing to the back post for Thomas to volley home and the Wales winger held up his black armband in tribute to eight-year-old Potters fan Ollie Royles who died this week following a cancer battle.
Stoke's lead lasted just 11 minutes and Andrew Moran found Devine, as he raced through from his own half, and he applied a clinical left-footed finish into the far corner.
The game was feisty and Preston skipper Ben Whiteman was extremely lucky to escape with just a yellow card when he caught Thomas high and late.
Preston went up through the gears and took the lead when Dobbin crossed from the right to the near post, where the unmarked Osmajic headed home his eighth club goal of the season from four yards out.
Stoke faded in the second half and Preston scored a third on the hour when Osmajic turned creator to feed Devine and he coolly chipped Stoke goalkeeper Tommy Simkin for his eighth of the campaign.