Police say they arrested three suspects including a custodian of the Sufi shrine in Sargodha city in central Punjab province.
Twenty people were tortured and then murdered at a Pakistani Sufi shrine early on Sunday by men wielding batons and knives, police said.
Four women were among those killed at the Shrine of Mohammad Ali in Sargodha, a town in the central Punjab province, according to police.
Police said they had arrested three suspects including the shrine's custodian.
At least four people were also wounded.
"The 50-year-old shrine custodian Abdul Waheed has confessed that he killed these people because he feared that they had come to kill him," regional police chief Zulfiqar Hameed said.
"The suspect appears to be paranoid and psychotic, or it could be related to rivalry for the control of shrine," he said, adding that the investigation was continuing.
TRT World's Sarah Jones has more on the story.
Bruises and wounds
Pervaiz Haider, a doctor in a Sargodha hospital, said most of the dead were hit on the back of the neck.
"There are bruises and wounds inflicted by a club and dagger on the bodies of victims," he said.
Punjab Chief Minister Shahbaz Sharif has asked for a police report on the investigation within 24 hours, a senior government official said.
Visiting the shrines and offering alms to the poor — and cash to the custodians — remains very popular in Pakistan, where many believe this will help get their prayers answered.
There have been cases of people dying during exorcism ceremonies at some Sufi shrines across Pakistan, but mass killings are rare.
For centuries Pakistan was a land of Sufism, a mystical branch of Islam whose wandering holy men helped spread the religion throughout the Indian subcontinent in the thirteenth century.