Kris Welham's hat-trick proved in vain as Castleford came from behind to beat Hull KR 34-30.
Nick Youngquest's second try of the night just a minute from time won it, Kirk Dixon adding his fifth goal of the game to add to his earlier try.
Rovers had their noses in front almost throughout the seesaw contest, but tries from Josh Griffin, Richard Owen and Danny Orr helped turn it round.
Josh Hodgson and Lincoln Withers grabbed the Robins' other two tries.
The Tigers looked to be heading for their eighth successive defeat when they trailed 30-22, but they staged a great recovery to achieve their first home win of the season.
Cas recalled Daryl Clark, who replaced hooker Ryan Hudson (calf injury) and on-loan Lee Mitchell, who took over at centre from Australian James Grehan, but they were again without centre Joe Arundel (shoulder).
Liam Salter replaced Sam Latus on the wing in the only change to the Hull KR side that beat Huddersfield Giants.
When Withers darted over for the visitor's fifth try and Dobson kicked his fourth goal to make it 28-18, Rovers looked on course for victory.
Even when Cas hit back and Dixon tore over from Rangi Chase's long pass, Dobson's 59th-minute penalty goal gave Hull KR an eight-point cushion.
But the Tigers struck back again two minutes later when Orr crossed, Dixon adding the conversion.
McDonnell then looked to have rescued Rovers with a magnificent tackle on Owen. But the Cas full-back put in Youngquest for his last-gasp winner, goaled by Dixon.
FROM THE DRESSING ROOM
Castleford coach Ian Millward:
"I was impressed with the blokes at the back end and the way they held their composure and increased their intensity in the second half. We've still got issues with our consistency. We build some pressure then release it.
"I thought a couple of tough calls went against us as well, but it's great to be talking about a victory and we can improve on that. Some of the errors we make are a bit naive. At times, the desire's there. It's just getting the right sort of structure in place and sticking to it.
"But we led at half-time and led at full-time and that's a true indication of the game. I was impressed with the fans and the way they were got behind the team and kept trying to lift the players. We had a chance to draw the game and chose not to with a kick because I felt we were dominating the game."
Hull KR coach Craig Sandercock told BBC Radio Humberside:
"In the last 10 minutes, all we did was defend our own line. A couple of errors and key decisions went against us meant that all we did was defend our own line and, to Castleford's credit, they were good enough to score with seconds to go.
"Refereeing decisions, I can't do anything about. "It's a big call for the referee to make at the end allowing our player to be lifted off the ground into the in-goal area because my interpretation of the rules are that once a player is on the deck once a hand is placed on him that constitutes a tackle.
"I need to have a look at that again because that young referee has changed the course of the game and I just hope he has got that decision right. If he hasn't, he has cost me two points and I expect the full consequence of that decision to be placed on the referee if he has got it wrong.
"In the first half we were guilty of too many unforced errors. We looked good in attack, but we didn't pay Castleford's defence enough respect. To Castleford's credit they came back at us and Rangi Chase was too good for us tonight."
FRIDAY NIGHT'S LINE-UPS
Castleford: Owen; Youngquest, Mitchell, Dixon, Griffin; Chase, Orr; Walker, Clark, Massey, Ferres, Holmes, Emmitt.
Replacements: Snitch, Jones, Millington, McGoldrick.
Hull KR: McDonnell; Salter, Horne, Welham, D Hodgson; Murrell, Dobson; Clinton, Withers, Wheeldon, Mika, J Hodgson, Watts.
Replacements: Paea, Taylor, Lovegrove, Cox.
Referee: Robert Hicks (Oldham).