John was born at Vila Viçosa and succeeded his father Teodósio II as Duke of Braganza when the latter died insane in 1630. He married Luisa de Guzman (1613-1666), eldest daughter of the Duke of Medina-Sidonia, in 1633. By the unanimous voice of the people he was raised to the throne of Portugal (of which he was held to be the legitimate heir) during the revolution on December 1, 1640, against the Spanish king Philip IV.
His accession led to a protracted war (the Portuguese Restoration War) with Spain, which only ended with the recognition of Portuguese independence in a subsequent reign (1668). Portugal signed alliances with France (June 1, 1641) and Sweden (August 1641) but by necessity its only contributions in the Thirty Years’ War were in the field against Spain and against Dutch encroachments on the Portuguese colonies.
In Spain, a Portuguese invasion force defeated the Spanish at Montijo, near Badajoz, in 1644. Abroad, the Dutch took Malacca (Jan 1641) and the Sultan of Oman captured Muscat (1648). Nevertheless the Portuguese, despite having to divide their forces among Europe, Brazil and Africa, managed to retake Luanda, in Angola, from the Dutch in 1648 and, by 1654, had recovered most of Brazil, effectively ceasing to be a viable Dutch colony. This was countered by the loss of Ceilan (Portuguese Ceilão), present day Sri Lanka, to the Dutch who took Colombo in 1656.
King John IV died in 1656 and was succeeded by his son Afonso VI. His daughter Catarina (Catherine of Braganza) married King Charles II of England.
John was a patron of music and the arts, and a considerably sophisticated writer on music; in addition to this, he was a composer. During his reign he collected one of the largest libraries in the world, but it was destroyed in the Lisbon earthquake of 1755. Among his writings is a defense of Palestrina, and a Defense of Modern Music (Lisbon, 1649). His most famous composition is a setting of the Crux fidelis, a work that remains highly popular during Lent amongst church choirs.