Some dude who is accused of sexually assaulting a 4-year-old girl allegedly tried to kill himself by driving his van off a ledge in Colorado. And it almost worked...

In what has to be one of the craziest twists of fate ever, the perp's van caught a ledge -- and a search and rescue team got to the guy before karma did.

Dude went to the hospital, but as soon as he gets out, cops say he'll be immediately arrested.