In 1808, when Napoleon Bonaparte invaded Spain, Sor began to write nationalistic music for the guitar, often accompanied by patriotic lyrics. Sor was even part of traveling military bands that would play protest music on the streets. He was also promoted to captain in Córdoba and may have fought battles against the French at this time. After the defeat of the Spanish army, however, Sor accepted an administrative post in the occupying government. Here he was to be officially labeled an afrancesado along with the other Spaniards who abandoned their defense of Spain to embrace the French Revolutionary ideas. After the Spanish repelled the French in 1813, Sor and other afrancesados left Spain for fear of retribution. He went to Paris, never to return to his home country again.