A Tehachapi correctional officer charged with murder in the shooting of his wife’s lover offered a homeless man $5,000 to burn down the wife’s apartment the day before the slaying, according to court documents.

The man told police he refused Rigoberto Sanchez’s offer, but did agree to accompany him in burglarizing the apartment on May 27, the newly released documents said. The man admitted to damaging a surveillance camera outside while Sanchez, 39, stole items from the residence.

The following evening, according to police, Sanchez returned to the apartment on Valleyview Drive in Bakersfield and opened fire from a bedroom window at his wife and Edwin Lima, another correctional officer whom she was dating.

Lima, 31, was struck multiple times and died. The wife, Sandra Sanchez, was unharmed. She’s also a correctional officer.

According to the documents, 11 bullets were removed from Lima’s body. The majority appeared to strike him while he was on the ground.

In addition to murder and other charges related to the shooting, Sanchez faces two first-degree burglary charges stemming from the May 27 incident and another break-in March 9.

Deputy Public Defender Paul Cadman, Sanchez’s attorney, said the shooting was not premeditated.

“Mr. Sanchez continues to take full umbrage in the assertion that he is guilty of first-degree, premeditated, with malice aforethought murder under circumstances in which his employer, CDCR, was well aware of the infidelity involved and either condoned or encouraged this type of sophomoric behavior among its correctional officers,” Cadman said.

“Only someone with legal typhlosis would dare to believe this is a case of first-degree murder,” he said.

“Typhlosis” is a medical term for blindness.

In response, California Department of Corrections and Rehabilitation spokesman Bill Sessa said policies are in place regarding professional behavior on the part of prison staff as well as “over-familiarization” with inmates.

“When our officers are in the prison, we hold them to a high professional standard so that they’re not vulnerable to being compromised by the inmates,” he said. “But on their own time they are free to have their own lives, and what they do there is beyond our control.”

Sessa said CDCR’s main concern is officers are not involved in illegal activity.

The court documents provide greater detail on both the shooting and the events that occurred afterward.

Sandra Sanchez told officers she dropped when she heard gunshots as she and Lima were settling down to watch TV. She crawled out of the bedroom, closing the door behind her.

Her son, who also lives at the apartment, ran out of his bedroom. She told him to go back inside, and the two of them huddled together while she called 911, the documents said.

Hearing several people outside, and believing her husband had left, Sandra Sanchez said she went back into her bedroom and grabbed a gun from a holster Lima was wearing. She said she racked the handgun’s slide and believes she accidentally ejected a round from the chamber.

Officers soon arrived, but Rigoberto Sanchez was gone.

As it turned out, police had already been searching for Rigoberto Sanchez that evening in connection with the May 27 burglary. He and the homeless man were caught on surveillance video Sandra Sanchez provided to investigators.

Before the shooting, police went to Rigoberto Sanchez’s house in the 1600 block of Abrazo Street to serve a search warrant, the documents said. Sanchez had already left for his wife’s apartment.

Afterward, he fled to Mexico, where he eluded authorities until his capture on June 21.

Interviewed by investigators, Rigoberto Sanchez expressed anger and frustration over the affair. He said he married Sandra Sanchez in 2003, and helped raise her children.

“I took on a big responsibility, raising two kids that weren’t mine, to get treated like (expletive),” he told investigators.

He said his wife had become distant, and he long suspected she was having an affair, according to the documents. After discovering Lima was her boyfriend, he confronted him, and on two occasions challenged him to a fight.

Lima, also married, had a bad reputation, Rigoberto Sanchez said. He told investigators he believed Lima was a “dirty cop” who smuggled contraband into prison, but had no evidence.

The night of the shooting, Rigoberto Sanchez said, he called his wife multiple times, and on a couple of occasions spoke with Lima. He said Lima taunted him over the affair, bragging about having sex with his wife and how he would send Rigoberto Sanchez a video of them engaged in sex acts.

Rigoberto Sanchez said he became infuriated and drove over to the apartment, the documents said. He said he doesn’t remember taking aim while firing, and doesn’t believe either his wife or Lima fired at or threatened him.

He said he didn’t sleep for three days afterward.

Rigoberto Sanchez denied offering the homeless man $5,000 to burn the apartment, but admitted to buying him a couple cheeseburgers for trashing the surveillance camera, according to the documents.

During the interview, Rigoberto Sanchez and investigators discussed a tattoo on his left shoulder. He said he got the tattoo in memory of a friend who had also been a correctional officer.

This friend, Rigoberto Sanchez told investigators, shot his wife then killed himself in 1999. Rigoberto Sanchez said a rumor went around afterward that he had been having an affair with his friend’s wife, and that he killed him.

He said the rumors weren’t true.

Sanchez is next due in court Aug. 24. He’s being held without bail.