In March 1813, threatened by the Anglo-Spanish army, Joseph had left the capital and the Allied offensive intensified and culminated in the Battle of Vitoria in June. French troops were finally evicted from Spain following the conclusion of the Siege of San Sebastián in September 1813, so removing any possibility of a return. In December 1813, the Treaty of Valençay provided for the restoration of Ferdinand VII.