was signed. The raja allowed them to build a factory at Cochin (and upon Cabral's departure Cochin allowed thirty Portuguese and four Franciscan friars to stay in the kingdom). Assured by the offer of support, the raja declared war on his enemy, the Zamorins of Calicut. In 1502, a new expedition under the command of Vasco da Gama arrived at Cochin, and the friendship was renewed. Vasco da Gama later bombarded Calicut and destroyed the Arab factories there. This enraged the Zamorin, the ruler of Calicut, and he attacked Cochin after the departure of Vasco da Gama and destroyed the Portuguese factory. The raja of Cochin and his Portuguese allies were forced to withdraw to Vypin Island. However, the arrival of a small reinforcement Portuguese fleet and, some days later of Duarte Pacheco Pereira and the oncoming monsoons alarmed the Zamorin. Calicut recalled the army and abandoned the siege. After securing the throne for the Raja of Cochin, the Portuguese got permission to build a fort – Fort Emmanuel (at Fort Kochi, named after the king of Portugal) – surrounding the Portuguese factory, in order to protect it from any further attacks from Calicut and on 27 September 1503 the foundations of a timber fort, the first fort erected by the Portuguese in India, were laid. The entire work of construction was commissioned by the local raja, who supplied workers and material. In 1505, the stone fortress replaced the wooden fort. Later, for a better defence of the town, a fort called "Castelo de Cima" was built on Vypeen Island. At the departure of the Portuguese fleet, only Duarte Pacheco Pereira and a small fleet were left in Cochin. Meanwhile, the Zamorin of Calicut formed a massive force and attacked them. For five months, Cochin kingdom was able to drive back Calicut's assaults, with the help of Pacheco Pereira and his men. The ruler of the Kingdom of Tanur, who was a vassal to the Zamorin of Calicut, sided with the Portuguese against his overlord at Kozhikode. As a result, the Kingdom of Tanur (Vettathunadu) became one of the earliest Portuguese colonies in India. The ruler of Tanur also sided with Cochin. Many of the members of the royal family of Cochin in 16th and 17th centuries were selected from Vettom. However, the Tanur forces under the king fought for the Zamorin of Calicut in the Battle of Cochin (1504).