Unidentified gunmen shot dead three security troops outside a mosque in Pakistan on Tuesday.

The gunmen, who were on a motorcycle, opened fire on the troops deployed outside a mosque located in a residential area in Karachi, Major General Bilal Akbar, the director-general of Pakistan's paramilitary Rangers told The Associated Press.

Local reports said that there were four gunmen and the mosque located in the Ittehad Town area of Karachi was their main target.

According to Pakistani newspaper, Dawn, the gunmen were going to attack the mosque but on seeing the security personnel outside the mosque, they targeted them instead.

There were eight Pakistani rangers in the vehicle, when the shooting took place. The condition of a fourth soldier injured in the shooting is said to be critical.