Hugh Hefner truly did have a ride or die by his side in Crystal Harris ... a pleasant surprise to family and friends initially skeptical of the 31-year-old's motives.

Playboy sources tell TMZ ... Crystal surprised the hell outta a lot of people when she stood by Hef's side in his declining years as he got older and became more frail. They actually called Crystal -- who at 26 married Hef in 2012 -- a pillar of strength.

Case in point ... Crystal was at Hef's doctor's appointments and the architect behind game and movie nights to keep his spirits high. When Hef was placed on bed rest, Crystal constantly was by his side.

The family initially was concerned that as Hef got older she wouldn't be there to support him, but she flipped the script with her attentiveness, and we're told the family's immensely grateful for her vigilance.

It's no wonder Hef wanted to take care of Crystal with a sick pad and $5 million long before his death ... she proved herself early on and remained a constant until Hef died peacefully last week.

He was 91. #RIP