In 1900 he was removed from the General Staff for his anti-semitic, anti-Dreyfusard attitude. Nevertheless, Castelnau later became deputy to Joseph Joffre from 1911 to 1914, and helped develop the strategic Plan XVII for the recapture of Alsace-Lorraine as part of an invasion of Germany. In 1914 with war imminent, General de Castelnau was put in command of the French 2nd Army facing the oncoming Germans in Belgium. Under his leadership, in August 1914, the French 2nd Army was decisively routed by the Germans at the Battle of the Frontiers under Crown Prince Rupprecht of Bavaria, with the initial French 2nd Army offensive (along with the French 1st Army) being driven back by the Germans 25 km (16 mi) from the positions where the offensive had initially begun on 14 August. By the end of August, however, the French won back most of the territory lost in the hard-fought Battle of the Trouée de Charmes. The Battle of the Trouée de Charmes was a definitive victory for the Second Army; in stopping the Germans from passing through the Trouée de Charmes, de Castelnau possibly saved the French from disaster, but during this battle he lost his son Xavier, killed in action on August, 20th. Later, his two other sons Gerald and Hugues were to be killed in action in 1914 and 1915. The French were able to then organize a defense at Nancy and hold the city after victory in the Battle of Grand Couronné. It was suggested that this battle was decisive in the protection of Paris, by binding up significant German resources in static trench warfare for the duration in Lorraine.