the local legends, both islamic and hindu, say of the arrival of malik ibn dinar and his company with them royal letters from the ceraman perumal [the last king of the cera perumal kingdom, c. 1089- 1122 ad] to different native chiefs seeking their assistance to the missionary activities and establishment of mosques. the mosque is a former hindu temple dedicated to god subramanya. hindu inscriptions can still be seen on the pillars and base walls of the mosque. the madayi mosque was built with the assistance of the kolattiri raja to whom also there was a letter from the last cera perumal. according to shaikh zain ud-din makhdum, the first "qadi" of the new mosque was malik ibn 'abdu rahman.