He suppressed with an iron hand all opposition against the central government and was able to repulse an attempted landing by British and Catalan forces in 1704. But in 1705, he was unable to withstand a second attack on the city, as a consequence of which Barcelona and the whole of Catalonia went over to the camp of Charles of Habsburg, the Austrian pretender to the vacant Spanish Crown.