The captain's emphatic free-kick in the fourth minute of injury time took him to 250 goals for the club, one clear of previous record scorer Sir Bobby Charlton, and salvaged a point to extend United's unbeaten run to 17 games in all competitions.
A first-half own goal from Juan Mata had looked enough to give Mark Hughes' side a third win in their last four league encounters at home to United and inflict a damaging blow on the visitors' top-four chances.
Mata missed a golden chance to equalise in the first half, while Paul Pogba also came close, but an organised defensive performance from Stoke kept them at arm's length for much of the contest.
United rescued a late draw against Liverpool at Old Trafford last Sunday but they looked insipid in attack before Rooney, on as a substitute, curled in from 20 yards out moments before the final whistle.
The result lifts Stoke onto 28 points while United move on to 41, three behind fourth-place Arsenal, having played a game more.
Stoke, who showed off new signing Saido Berahino to the bet365 Stadium crowd before kick-off, started brightly but Lee Grant was fortunate to escape a nervy moment as he fumbled a cross from Daley Blind, only for the home side to clear their lines under pressure.
Chances were limited in the early stages but it was Stoke who benefited from a stroke of luck to take the lead in the 19th minute. Marko Arnautovic picked out Erik Pieters' run inside the penalty area, and his low cross clipped the foot of Mata and the leg of David de Gea before nestling in the net.
United at last mustered an effort on target after 27 minutes but Marouane Fellaini's header was comfortably dealt with by Grant, before Mata ballooned the ball over the crossbar with the goal gaping after Zlatan Ibrahimovic picked him out at the far post.
Ibrahimovic himself should have done more when played through by Henrikh Mkhitaryan and Chris Smalling nodded over from close range as United began to build some sustained pressure.
Grant was twice called into action to preserve the half-time advantage, tipping Fellaini's scuffed volley over the bar before beating away Pogba's first-time strike from a corner, and United's dominance showed little let-up after the break.
Referee Mark Clattenburg dismissed penalty appeals from Mata after the ball struck the arm of the sliding Pieters but the visitors' efforts continued to yield little by way of chances as the Stoke rearguard stood firm.
Substitute Marcus Rashford curled a good effort narrowly wide of the top corner and Pogba blasted beyond Grant's right-hand post, but there remained a stark lack of attacking inspiration and the Stoke goalkeeper remained largely untroubled.
Rooney headed a half-chance over and Jesse Lingard crashed a shot off the top of the crossbar, but Stoke's resistance was finally ended when Rooney whipped a stunning effort into Grant's top-left corner from a tight angle to earn a dramatic point and a slice of United history.