IOWA CITY, Iowa — A homeless man facing car burglary and drug charges was released from jail two days before he allegedly killed a 38-year-old mother in a random home invasion that has shocked Iowa’s second-largest city, court records show.

Timothy Evans, 38, had been jailed on a $5,000 cash-only bond until a judge ordered the unemployed felon released on his own recognizance last Friday. A prosecutor with the Linn County attorney’s office agreed to the release under an arrangement with Evans’ defense lawyer.

Less than 48 hours after he left jail, investigators say Evans broke into a detached garage early Sunday at the Cedar Rapids home of Gina Frederiksen. They say he intended to commit a burglary, then assaulted the mother of three young children during a violent struggle, and set the garage on fire to destroy the evidence.

Police responded to the home Sunday morning after neighbors called 911 to report an explosion. An officer found Frederiksen suffering from traumatic injuries to her head and other body parts in the fiery doorway of the garage. She later died at a hospital, and a medical examiner ruled the death a homicide. Visitation for Fredericksen, an administrative assistant at a financial company, is scheduled Sunday in her hometown of Cedar Falls.

Investigators arrested Evans on Tuesday after witnesses told police that he had confessed to the homicide and arson in detail, and that he was seen on surveillance video attempting to break into at least one other home that morning. He’s charged with first-degree murder and is being held on $2 million bond.

Nicholas Maybanks, the first assistant Linn County attorney, said Thursday that Evans’ release from jail last week was “very unfortunate” but that no one in his office did anything wrong in agreeing to it. He noted that Evans was facing only aggravated misdemeanor burglary and theft charges in that case.

“It’s obviously very unfortunate but I can’t say that there’s anything that we did that was improper or out of practice. You can’t predict these things,” he said. “Nobody has a crystal ball.”

Evans was jailed April 16, a day after he allegedly broke into an unoccupied car in Cedar Rapids and stole items valued at less than $200.

At the time, Evans had a warrant out for his arrest in neighboring Jones County after skipping his arraignment in a felony drug possession case stemming from a March 2 traffic stop in which Evans allegedly had a bag of methamphetamine and needles. He was charged with possession of a controlled substance as a repeat offender, since he had at least three prior felony drug convictions. A judge ordered him released on pretrial supervision by the Department of Corrections, which typically involves routine check-ins with an officer.

Evans was also suspected in a November 2017 arson at a Cedar Rapids houseboat that had been burglarized. Investigators say that a crime lab database had a hit suggesting that DNA taken from a cigarette butt at the crime scene was a potential match for Evans. They obtained a DNA sample from him in February in hopes of confirming the match, but he hasn’t been charged and the case remains under investigation.

The order that released Evans from jail was signed by Judge Russell Keast and said only, “By agreement of the parties, the defendant is released on his own recognizance pending further proceedings.” That means Evans didn’t have to post bond or face any other conditions of supervision. The Jones County warrant was lifted the same day after his public defender filed a written arraignment on his behalf.

Josh Irwin, a public defender representing Evans, declined comment. Judicial Branch spokesman Steve Davis said Keast couldn’t comment.