First mosque outside Arabia, must have been in Egypt. At the time of Arab-Muslim conquest of Egypt mid-7th century (640 c.e.) that was the period of Muslim expansion outside of what we can say for argument sake original Arabia. Yes, Egypt today is known as part of Arabia, but wasn't a part of Arabia before Arab conquest, it had a distinctive "Egypt" identity separate from it's Arab identity today. Before, Arab-Muslim conquest in 640 c.e, Egypt was apart of the Byzantine empire.
We know Islam spread to Egypt and Iran before it spread to Pakistan. Islam arrived to Egypt and Iran in 7th century, while in Pakistan the early 8th century. The first masjid built in Egypt is Mosque of Amr ibn al-As built in 642 c.e. So approximately 2 years after Muslim conquest of Egypt. This makes reasonable sense. This fact alone invalidates the first mosque outside of Arabia was in Pakistan or elsewhere. Some will argue Egypt is "Arabia" well if you lived during the 7th century, I'm sure no Arab back then would have considered Egypt to be apart of Arabia, rather it was "Egypt" itself and happened to be apart of the Byzantine empire.
Anyways, if not Egypt then must be Iran (because I am not exactly sure), as these two locations were the primary territories of Muslim conquest and civilization outside of the Arabian peninsula. There is a chance I am wrong about this but with the information available to us today I'm sure the first mosque outside of Arabia wasn't in Pakistan, nor "Kerala" as one member stated definitively, but Egypt or Iran.
Regards, A1