Texas executed a man on Wednesday who fatally shot his ex-wife and four others in 1997 with a hunting rifle in a killing spree launched when he found her having sex with another man, a prisons official said.

Coy Wesbrook, 58, was pronounced dead at 8:04 p.m. after receiving a lethal injection at the state's death chamber in Huntsville. His execution had been delayed by about two hours because of a last-minute appeal.

The execution was the 535th in Texas since the U.S. Supreme Court reinstated the death penalty in 1976, the most of any state.

Wesbrook told a court he went to the Houston-area home of his former wife, Gloria Coons, seeking to reconcile. When he arrived, he found other people in the residence and began drinking with them, court documents showed.

RELATED: Maine governor supports publicly beheading drug dealers: Report

Two men slipped into his wife's bedroom and when he went in, he found her having sex with one of them. He then went to his truck to fetch his gun.

He went back and fatally shot anyone still on the premises, killing his ex-wife, Antonio Cruz, Ruth Money, Anthony Rogers and Kelly Hazlip.

He then walked to his truck and waited.

Wesbrook, a former security guard, could be overheard saying: "I did it. I did it. I did what I had to do," neighbors testified.

One man he shot to death was in the yard and the other victims were found inside. All had been shot at close range and his ex-wife was shot last, court documents showed.

It took a jury about 90 minutes to sentence him to death.

Lawyers for Wesbrook tried to have the execution halted, arguing his rights had been denied and he was mentally impaired.

In an interview with the Houston Chronicle published on Monday, Wesbrook said he spent his time studying the Bible, reading religious books and listening to gospel shows on the radio.

He added he was ready to die.

"I'm looking forward to it," he told the newspaper.