The Irish ran in three tries through Conor Murray, Stockdale – the prolific winger's 13th try in 16 Tests – and Keith Earls.
Their joy at the win may be tempered by how serious an injury world player of the year Johnny Sexton suffered in the first-half.
In ending a run of seven Scotland home wins in the Six Nations, Joe Schmidt's side became the first visiting side to record a championship victory since England in 2016.
Ireland next play Italy in Rome in a fortnight while the Scots – who lost key player Stuart Hogg to injury also in the first-half – are away in Paris against France.
Murray and Stockdale struck in the opening 16 minutes of a breathless first-half in which both teams lost their star men to injury, Hogg departing after 16 minutes and a battered Sexton with an accumulation of wounds seven minutes later.
A 28th minute try by Australian-born centre Sam Johnson helped Scotland narrow the gap to 12-10 by half-time – only for Earls' 55th minute score to nudge Ireland towards a victory that will lift their morale following their 32-20 loss to England in Dublin.
Ireland also gained a psychological boost ahead of their opening World Cup pool match against the Scots in Yokohama in September.
Scotland were on the front foot from the off and after six minutes Greig Laidlaw kicked them in front with a penalty from in front of the posts.
The lead lasted just four minutes.
Stockdale chipped the ball up the left wing and Tommy Seymour’s sloppy pass to Sean Maitland hit the deck, allowing Murray to collect the loose ball and bag the opening try after ten minutes.
Sexton was injured in the move and, after receiving treatment, the Leinster fly-half pushed his conversion attempt wide of the posts, leaving Ireland in front 5-3.
Prior to that counter attack, Hogg had damaged his shoulder and when the Scotland full-back made way for Blair Kinghorn Ireland struck again.
Stockdale took a feed from Sexton just inside the Scotland half and the 22-year-old Ulster flyer motored 50m to the line.
Murray assumed kicking duties from Sexton and made no mistake with the conversion, stretching Ireland's lead to 12-3.
Sexton left the field with a head injury after 23 minutes and five minutes later his replacement, Joey Carbery, threw Scotland a chance to let Scotland back into contention.
In attempting to find centre Bundee Aki, the Munster fly-half only succeeded in feeding Finn Russell.
The charging Scotland outside-half was stopped shy of the line by Earls but popped up a pass for Johnson to score his first international try.
Laidlaw's conversion narrowed the gap to 12-10 and Scotland might have gone into the half-time break with a lead had Ireland not absorbed 25 phases of pressure with a resolute green wall of defence just before the interval.
The Scottish defence produced something similar to repel Ireland early in the second half, a prolonged multi-phase attack coming to an end with a thumping tackle on Earls by hooker Stuart McInally.
Ironically, it was some slack Scottish defending that allowed Carbery to burst over the halfway line before shipping out a long, looping pass for Earls to score Ireland's third try after 55 minutes.
Carbery nailed the conversion to stretch the lead to nine points.
Laidlaw narrowed the advantage to 19-13 with a second penalty success but Carbery made it 22-13 with a 68th minute penalty with what proved to be the final scoring action of the match.AFP