In a statement issued by his spokesperson, Ban said he is "deeply dismayed" by repeated targeting of innocent people on account of their religious beliefs and in their places of worship.
"There is no justification for such crimes," he said.
The Secretary-General called on the Pakistani authorities to bring swiftly to justice the perpetrators and urged them to redouble their efforts to protect religious and ethnic minorities and to combat terrorism in all its forms.
The attack comes just two weeks after nearly 60 people were killed in another assault on a Shia mosque in southern Pakistan, which the UN chief also condemned.
The Secretary-General extended his heartfelt condolences to the victims' families, the Government and people of Pakistan.
At least 20 people were killed and over 50 injured when Kalashnikov-wielding Taliban suicide bombers stormed a crowded minority Shia mosque in Pakistan's restive northwest during Friday prayers, opening fire and exploding bombs in a revenge attack, the latest in a series of sectarian violence to hit the country.