A suicide bomber shouted "Allahu akbar" and blew himself up in a packed mosque in northwestern Pakistan, killing at least 25 people and wounding 30 during Friday prayers, a local official said.