Oscar Ayala-Arizmendi is accused of the kidnap and rape of a 27-year-old female.Twin Falls County Sheriff's Office

A woman has been rescued from a home rigged with electrical traps after being held captive as a sex slave for 18 months, Twin Falls County police have confirmed.

The 27-year-old victim had been kept in a rural house on the outskirts of Buhl, Idaho, where detectives found a complex construction of restraints, electrical wiring and fencing.

Twin Falls County Sheriff's detectives have arrested Oscar Ayala-Arizmendi, 36, a man living in the US illegally and charged him for the alleged kidnapping, rape and possession of drugs.

Ayala-Arizmendi has now been taken into custody, with his bail set at $1 million.

The alleged victim escaped on 8 April, at night time, with the help of her brother, she told detectives.

She told police she'd been held captive for nearly two years and forced to take methamphetamine once or twice a week. During the arrest, detectives saw Ayala-Arizmendi smash a glass pipe into a bathtub, which later tested positive for the drug.

According to a police report, the victim began to live with Ayala-Arizmendi more than two years ago, but he began to rape and beat her "more times than she could count". She stated that her captor would use a hammer and piece of wood to hit her, according to New York Daily News.

After her previously unsuccessful attempts to escape in the past, she said she was beaten and threatened with a pillow and a handgun to her head. She told detectives that Ayala-Arizmendi had threatened to "cut her up into small pieces and flush her down the toilet".

At night, she said the suspect raped her on several occasions. Confined to the bedroom, she often was forced to use a rubbish bin for a toilet.

Twin Falls County Prosecutor Grant Loebs told US News that following the woman's report, police worked for the next two and a half weeks to gather evidence to make the arrest.

Ayala-Arizmendi's house was searched, with police finding evidence to back up the victim's testimony, including chains and locks mounted to the walls of the home and a bucket filled with human waste in the bedroom.

A contraption of wood and metal secured the entrance to the room and Investigators also unearthed a handgun and a box of ammo.

Electrical wiring surrounded the house, which detectives believe was set up to shock anyone who tried to escape. The wires were attached to several electrical outlets in the house.

The victim told police that she'd tried to leave Ayala-Arizmendi's house on at least three or four occasions, but returned after he threatened to hurt her.

She says she eventually escaped after her brother and his friends forced their way into the house, after which she was freed with just the clothes she was wearing.

Ayala-Arizmendi's next court appearance is scheduled for 23 May. US Customs and Border Protection officials also are investigating Ayala-Arizmendi's legal status in this country.