Madrid coach Jose Mourinho rested several key names against the Primera Division basement boys with a view to Tuesday's Copa del Rey semi-final second leg against Barcelona, but the decision seemed to backfire when Riki fired Depor in front 10 minutes before the interval.
The home side then had several chances to extend their lead but were made to rue some poor finishing when Kaka equalised in the 73rd minute, while Higuain sealed victory for the visitors two minutes from time.
Karanka feels a different mindset among his team after the interval was the reason for their lucky escape.
"From the first minute of the second half we saw a change of attitude," he said on realmadrid.com.
"We didn't win because of the substitutions, which were made in the 12th minute of the second half, but because of the change we made.
"It was the attitude of all the players that sparked the comeback.
"We knew what we were going to come up against at Depor. We could have been more than one goal down at half-time, they were much better than us in the first half, but they didn't make the most of their chances and they have paid the price."
Karanka reserved praise for forward Kaka, who was given a rare 90 minutes by Mourinho and responded with the equaliser.
"It's true that honestly he is playing well," Karanka said of the Brazilian.
"His state of mind helps him and this is important for the team, that he is playing well and that he is another alternative. That is always positive."