The custodian of a shrine in Pakistan has been charged with murder and terrorism, police said, after allegedly torturing and killing 20 people with knives and clubs.

Abdul Waheed and two others were arrested outside the Ali Muhammad Gujjar shrine near Sargodha in the Punjab province late on Saturday after they drugged the devotees before beating them with sticks and stabbing them to death, police said.

"They [the trio] will be presented in court today [Monday] for us to obtain a judicial order for physical custody, so that we can continue our investigation," local police officer Nusrat Ali told Al Jazeera.

"A terrorism charge has been included in the charge sheet."

The 50-year-old Waheed told police he killed the worshippers because he thought they might kill him one day, Arshad Abbas, an investigator in the case, told AFP news agency.

Some officials said Waheed had mental health problems and had used violence on followers before.

Visits to shrines and offers of alms for the poor - and cash to custodians - remains a very popular custom in Pakistan. Many believe this will help get their prayers answered.

Pervaiz Haider, a doctor at a Sargodha hospital, said most of the dead were hit in the back of the neck.

"There are bruises and wounds inflicted by a club and dagger on the bodies of victims," he told Reuters news agency.

Chief of the local police station Shamsher Khan said Waheed was found sitting outside the shrine when authorities reached the location.

"He had a dagger dripping with blood on him," said Khan. "He told us not to come near him otherwise he will attack us ... But we managed to arrest him and the two other men who were sitting outside the shrine with him.

"The whole shrine was filled with bodies. There were 20 dead bodies, including three women and 17 men."