According to Deputy Commissioner Liaqut Ali Chatha, the incident took place at the dargah of Muhammad Ali Gujjar in a village in Sargodha district, around 200 km from Lahore. The incident happened at around midnight.
Local police station chief Shamshir Joya said the victims, whose clothes were torn and bloodstained, appeared to have been given intoxicants. "We suspect that the victims had been given some intoxicants before they were murdered, but we will wait for a forensics report to confirm this suspicion," he added. Joya said the shrine was built in the area some two and a half years ago. When its former custodian died, Waheed -- a one-time employee of the national election commission -- took over.
"The suspect appears to be paranoid and psychotic, or it could be related to rivalry for the control of shrine," Mr Hameed said, adding that the investigation was under way. Adding to this, Mr Chatha said "it appeared that the caretaker of the dargah had first drugged the visitors and then stabbed and clubbed them to death." Punjab Chief Minister Shahbaz Sharif has asked for a police report on the investigation within 24 hours, a senior government official said.
The four injured people have been admitted to a hospital in critical condition.
According to tradition, "people would come to the dargah for cleansing their sins and allow the caretakers to beat them with clubs. But in this case the visitors were first drugged and then stabbed with daggers and hit with clubs, apparently during the cleansing process," Mr Chatha said.
According to senior police officer Bilal Iftikhar, one injured witness said there was a clash between two groups of the caretakers of the dargah over its possession. 19 people of both groups, including six members of one family, were killed, the police officer 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 shrines across Pakistan, but mass killings are rare.
Terror groups such as the Taliban and ISIS have carried out major attacks on Sufi shrines because they consider them heretical.
(With inputs from AFP and PTI)