The visitors had the game in their grasp at 1-0 with 10 minutes left after Jean-Louis Akpa-Akpro's 73rd-minute goal, but Dale collapsed under pressure to lose their npower League One status as the Spireites struck through Scott Boden (80) and Danny Whitaker (85).
"I think we were fortunate to win it and I think Rochdale were the better team but you've got to give credit to the players because they showed determination to keep going," said Wright.
"[Goalkeeper] Tommy [Lee] made a vital save at 1-0 because if we had gone two behind that would have been the end of the story."
Chesterfield now have to win their last two matches and hope other results go for them and Wright knows they still have a chance of beating the drop.
"We just have to keep going and first and foremost we've got to look after our own house. We have to try and win the games because there would be nothing worse if we don't win next week and another team gets beaten."