Police killed one of the militants in a gunfight around the mosque, in the wealthy Hayatabad district.
Another of the militants blew himself up with a suicide vest, and a third was arrested, police said.
Two weeks ago, another attack on a Shia mosque in Sindh province's Shikarpur district left more than 60 people dead.
Sunni militants linked to the Taliban said they had carried out the Shikarpur attack, which was the deadliest in years.
Pakistani Prime Minister Nawaz Sharif expressed his grief for the loss of life and said that the government remained committed to "eradicating the menace of terrorism".
Over the past decade, Pakistan has experienced an increasing number of sectarian attacks.
Most are carried out by hardline Sunni Muslim groups against Shias, who comprise about 20% of the population.(BBC)