century. The vacuum created economic opportunities for some Mappila traders, who also took on a greater role in the social and religious affairs in Malabar. The Portuguese tried to establish a monopoly in the spice trade in India, using violent naval warfare. Whenever a formal war was broke out between the Portuguese and the Calicut rulers, the Portuguese attacked and plundered, as the opportunity offered, the Muslim ports in Kerala. Small, lightly armed, and highly mobile vessels of the Mappilas remained a major threat to Portuguese shipping all along the west coast of India. Mappila merchants, now controlling pepper trade in Calicut in the place of the West Asian Muslims, drew Mappila corsairs and used them to transport the spices past Portuguese blockades. Some Mappila traders even tried to outwit the Portuguese by reorienting their trade to Western Indian ports. Some chose an overland route, across the Western Ghats, for the export of spices. By the end of the 16th century, the Portuguese were finally able to deal with the "Mappila challenge". Kunjali Marakkar was defeated and killed, with the help of the Calicut ruler, in c. 1600 AD. The Ali Rajas of Cannanore was given permission to send ships to even to the Red Sea, as a way of ensuring their cooperation. The relentless battles led to the eventual decline of the Muslim community in Kerala, as they gradually lost control of the spice trade. The Muslims — who had been depended solely on commerce — were reduced into severe economic perplexity. Some traders turned inland (South Malabar) in search of alternate occupations to commerce. The Muslims of Kerala gradually became a society of small traders, landless labourers and poor fishermen. The once affluent, and urban, Muslim population became predominantly rural in Kerala. The Tuhfat Ul Mujahideen written by Zainuddin Makhdoom II (born around 1532) of Ponnani during 16th-century CE is the first-ever known book fully based on the history of Kerala, written by a Keralite. It is written in Arabic and contains pieces of information about the resistance put up by the navy of Kunjali Marakkar alongside the Zamorin of Calicut from 1498 to 1583 against Portuguese attempts to colonize Malabar coast. It was first printed and published in Lisbon. A copy of this edition has been preserved in the library of Al-Azhar University, Cairo. Tuhfatul Mujahideen also describes the history of Mappila Muslim community of Kerala as