HILLSBOROUGH COUNTY, Fla. — The man accused of robbing a bank, carjacking and killing a man in Valrico attempted to end his life in jail, the sheriff's office said.

The Hillsborough County Sheriff's Office said James Hanson Jr., 39, managed to sneak a towel into a recreation area and hanged himself. The sheriff's office said a deputy saw Hanson's attempt to end his life and intervened.

The deputy performed lifesaving CPR on Hanson and called emergency responders. Hanson was taken to Tampa General Hospital, where he is in critical condition.

Previous: Deputies say carjacker admitted to murder, booked in jail

More: Man accused of carjacking man and killing him had history of problems in prison, documents say

Deputies say Hanson robbed the CenterState Bank Aug. 7 and then carjacked Mathew Korattiyil at gunpoint. Hanson is accused of killing Korattiyil and dumping his body at a nearby church.

Korattiyil was 68 years old, a father of three and a grandfather.

More: Community remembers man found dead after carjacking

Hanson is charged with premeditated first-degree murder, carjacking, grand theft of a motor vehicle, kidnapping, resisting an officer with violence and robbery.

Court documents show Hanson has a criminal history and was sentenced to life in prison at one point for armed robbery. He ended up making a deal for a 15-year sentence, which set him up for a July 2 release.

What other people are reading right now:

Make it easy to keep up-to-date with more stories like this. Download the 10News app now.

Have a news tip? Email desk@wtsp.com, or visit our Facebook page or Twitter feed.