Scotland were hanging on and it looked for all the world like Ireland would burst the dam until second row Sarah Bonar pounced for an interception and kicked ahead to take the play into the Ireland 22.
Ireland scrambled back but could not get the ball off the field in the final play of the half.
The Scots showed great composure and engineered space for Orr to slalom through for a superb score and give the home side an unlikely five-point lead at the break.
Djougang was not to be denied her try and ploughed over to level things up at 12-12, and Scotland’s cause was hampered further when Rhona Lloyd was sent to the sin bin for head-to-head contact with Costigan in the build-up to the score.
While some accuracy was lacking in their game, the Scots were doggedly staying in the game and when they got their chance of a rare foray into Ireland territory, they took their chance superbly.
The ball was whipped wide to Chloe Rollie and she fended off a tackle before slipping a beautiful pass out the back door for McLachlan to dive over in the corner.
In a match where they had been under the cosh for large spells, the home side now led 19-12.
But Ireland were undeterred and continued to put pressure on Scotland, most notably at scrum time.
The home side were barely back to their full complement when they lost another player to a yellow card, this time Helen Nelson for an infringement at a ruck as the Scots became more desperate in their defence of their try line.
The pressure eventually told when substitute Lane dived over and O’Brien slotted over the conversion to make it all square again.
There was one final twist when McGhie went over in the corner to pull a victory out the fire at the end of a breathless contest.
