by sea. His body was recovered by the Moors, decapitated and hung on the walls of Gibraltar for the next twenty-two years. Moorish rule over Gibraltar came to an end in August 1462 when a small Castilian force under the command of Alonso de Arcos, the governor of Tarifa, launched a surprise attack. The Castilians mounted their attack while Gibraltar's senior commanders and townspeople were away paying homage to the new sultan of Granada. After a short assault that inflicted heavy losses on the defenders, the garrison surrendered to Enrique de Guzmán's son Juan Alonso, now the first Duke of Medina Sidonia. The Moorish inhabitants were once again expelled en masse, to be replaced by Christians. Castilian and Spanish rule (1462–1704) Shortly after Gibraltar's recapture, King Henry IV of Castile declared it Crown property and reinstituted the special privileges his predecessor had granted during the previous period of Christian rule. Four years after visiting Gibraltar in 1463, he was overthrown by the Spanish nobility and clergy. His half-brother Alfonso was declared king and rewarded Medina Sidonia for his support with the lordship of Gibraltar. The existing governor, a loyalist of the deposed Henry IV, refused to surrender Gibraltar to Medina Sidonia. After a fifteen-month siege from April 1466 to July 1467, Medina Sidonia took control of the town. He died the following year but his son Enrique was confirmed as lord of Gibraltar by the reinstated Henry IV in 1469. In 1474 the new Duke of Medina Sidonia sold Gibraltar to a group of Jewish conversos from Cordova and Seville led by Pedro de Herrera in exchange for maintaining the garrison of the town for two years, after which time the 4,350 conversos were expelled by the Duke. His status was further enhanced by Isabella I of Castile in 1478 with the granting of the Marquisate of Gibraltar. On 2 January 1492, after five years of war, the Moorish emirate in Spain came to an end with the Catholic Monarchs' capture of Granada. The Jews of Gibraltar were, like those elsewhere in the kingdom, expelled from Spain by order of the monarchs in March that year. Gibraltar was used by Medina Sidonia as a base for the Spanish capture of Melilla in North Africa in 1497. Two years later the Muslims of Granada were ordered to convert to Christianity or leave. Those that did not convert left for North Africa,