The bomber slipped undetected through a side door, he said.
Provincial police chief General Raz Mohammad Mandozai also confirmed the presence of two suicide bombers, adding that the assailants were wearing burqas to hide their weapons and explosives.
Once inside the mosque, the two attackers also opened fire on the crowd before detonating their bombs.
Gardez public health department chief Wilayat Khan Ahmadzai said that more than 70 people in total had been killed and wounded, with many rushed to the city's civilian hospital.
Syed Sufi Gardezi, the senior cleric in the city of Gardez, put the death toll at 30. He described a scene of panic and distress outside the Imam-e-Zaman mosque as news of the explosion spread and relatives gathered.
Gardezi said the wounded were screaming for help and body parts of the dead were scattered throughout the single story mosque. The dead were all men and boys, he said.
Dr Mohammad Wali Roshan, a physician at a local hospital, said some of the relatives, armed with sticks and guns, were furious at the lack of security and began beating even medical personnel who arrived to help the wounded.
“They were shouting that there was no security and screaming for their loved ones,” he told The Associated Press in a telephone interview.
No one immediately claimed responsibility for the attack but the Islamic State affiliate in Afghanistan has targeted worshippers in the past. The group has also warned Afghanistan's minority Shias that their houses of worship would be targeted.