Afonso's reign saw the end of the Restoration War (1640–68) and Spain's recognition of Portugal's independence. He also negotiated a French alliance through his marriage. However, the king was physically and mentally weak. In 1668, his brother Pedro conspired to have him declared incapable of ruling, and took supreme "de facto" power as regent, although nominally Afonso was still sovereign. Queen Marie Françoise, Afonso's wife, received an annulment and subsequently married Pedro. Afonso spent the rest of his life and reign practically a prisoner.