At half-time, the visitors trailed 16-0, after Rob Kirby kicked three penalties and added the conversion to scrum-half Luc Jones’s try.
A determined Carnegie replied in the second half with a Jacob Umaga penalty from 40 metres out. Dan Temm, returning from the sin bin, then crossed from a line out.
Yorkshire were now putting the pressure on, full-back Umaga scooping up a loose ball to cross for a try, which he also converted.
Now the deficit was down to one point, at 16-15, and with 10 minutes remaining a maul collapsed and Dylan Donnellan scored in the corner.
Umaga converted from the touchline to make it 22-16 and complete the second-half recovery.
Doncaster Knights eased their relegation fears beating bottom club Hartpury 48-21.
Knights ran in six tries, all of which were converted by Dougie Flockhart who also chipped in with a couple of penalties.
The Doncaster pack produced another dominant display and were directly responsible for four of the tries with flanker Ollie Stedman bagging one in each half. But well though the pack played arguably the two stand-out performers were scrum-half Tom James and on-loan fly-half Sam Olver.
James capped another impressive game with a brace and Olver set up two tries and created other chances in a performance which will – provided he is not recalled by Ealing – make it difficult for Tongan international Kurt Morath to win back his place when he is fit.
Doncaster now have 26 points, six points above third-from-bottom Carnegie.