Roberto Carlos Magalhaes, a 30-year-old bricklayer, told detectives that the woman went into a trance and would "command him to stick the needles in the boy's body," police inspector Helder Fernandes Santana said in a telephone interview with The Associated Press.
The two held repeated sessions over several weeks, and perhaps longer, in which they inserted the needles in the child, Santana said.
"According to his confession, he acted under influence of the woman, but it was he who stuck the needles in the boy's body," the inspector said. The stepfather, the woman he said went into trances and another woman at some of the rituals have been arrested, though no charges have yet been filed.
Magalhaes initially denied involvement when he was first questioned by authorities on Monday, but confessed after police detained him on Wednesday, Santana said.
An enraged crowd of more than 100 people surrounded and hurled rocks at the police station in the small northeastern city of Ibotirama where the suspects were held Wednesday night. Santana said they broke out a window of his own car because they wrongly believed the suspects were in it.
Extra police were called in to restore order and protect the suspects, who were then taken to an undisclosed lockup for their own protection.
The child, meanwhile, was airlifted to the heart unit of a major hospital in northeastern Brazil Thursday because two of the needles are close to his heart, but it was not immediately clear when doctors might be able to remove them.
Surgeons at a hospital in the town of Barreiras in Bahia state, where the boy had been hospitalized since Sunday had decided not to try to remove any needles immediately for fear they could cause more damage.
Doctors located 42 needles in the boy, who was in stable condition after a 240-mile (390-kilometer) flight to the hospital in the coastal city of Salvador that has a special heart unit.
Hospital spokeswoman Susy Moreno said that an evaluation of how to treat or operate on the boy probably would not be finished until Friday. He was in an intensive care unit but was conscious.
The boy's mother, a maid, took him to a hospital in Ibotirama on Dec. 10, saying he was complaining of pain. Three days later, after X-rays revealed many of the needles, doctors moved him to the larger hospital in the nearby city of Barreiras.
The mother told police she didn't know how the needles got inside her son, whose name was not released because of his age.
The boy's father, Gessivaldo Alves, told a Brazilian newspaper that he visited the home where the boy was living and found unspecified items that could be used for black magic.
Santana said police are investigating to determine what sort of religious sect the stepfather and the women belonged to.
One of the doctors who treated the child, Luiz Cesar Soltoski, said he believed that the needles were stuck into the child's body one by one. Police have also concluded it would have been impossible for the boy to have ingested the needles - which have been also been found in a lung, his left leg and different parts of the thorax.
Associated Press Writer Alan Clendenning in Sao Paulo contributed.