A senior Pakistani security official says gunmen riding on motorcycles opened fire, killing three security troops deployed outside a mosque in a residential area in Pakistan's largest city, Karachi.

Maj. Gen. Bilal Akbar, the director-general of Pakistan's paramilitary Rangers, says a fourth Ranger was wounded in Friday's attack.

Akbar says the Rangers were inside a vehicle that was parked near the mosque when the assailants opened fire. In comments to local media, he says the attackers likely sought to target the mosque or a nearby seminary.

Karachi is capital of Pakistan's southern Sindh province and has been the site of frequent militant attacks in the past.