Don Juan Alonso Pérez de Guzmán y Afán de Ribera, 3rd Duke of Medina Sidonia (February 1464 – 1507) inherited the title in 1492, aged 28. In 1502, as Gibraltar was transferred to the Crown, the Marquisate of Gibraltar disappeared.
His mother is known as Leonor de Mendoza y Ribera, although he was known by using as his second name "Afan de Ribera". This could be because his mother was a Mendoza, and it was not unknown for women and ecclesiastics to use the name of their mother, in spite of her father being an "Afan de Ribera".
He married twice, being the father of the 4th, 5th and 6th Duke. Among his children were:
- Enrique Pérez de Guzmán, 4th Duke of Medina Sidonia, married, no issue
- Alfonso Pérez de Guzmán, 5th Duke of Medina Sidonia, declared incapacitated
- Juan Alfonso Pérez de Guzmán, 6th Duke of Medina Sidonia, married
- Leonor Pérez de Guzmán y Pérez de Guzmán, married Jaime I, Duke of Braganza, the most powerful noble in all of Portugal, and one of the most powerful nobles in all of Iberia