Stock, who has endured injury problems in recent seasons, pounced from 12 yards in the fourth minute of added time - his first goal since March 2009.
Middlesbrough, who have now taken just four points out of a possible 33 on their travels, made a flying start when Scott McDonald put them ahead inside four minutes.
Marvin Emnes set up the Australia striker, who fired into the bottom corner from 12 yards for his third goal in six games.
Doncaster levelled in the 22nd minute through in-form striker James Hayter. Former Sheffield United forward Billy Sharp delivered the cross and Hayter made no mistake with his header from six yards - his sixth goal in his last eight.
But just when it seemed the sides would have to settle for a draw, Stock popped up with the winner to ensure Doncaster made the perfect response to last Saturday`s 5-1 defeat at Leicester and condemned Boro to a ninth away loss this term.
Source: PA
Source: PA