The Peninsular War was fought mainly in Spain, where a long insurgency and allied campaign challenged Napoleon’s occupation. The conflict lasted from 1808 to 1814 and formed part of the wider Napoleonic Wars.
France initially invaded Portugal in 1807 by moving troops across Spain. Napoleon then intervened directly in Spanish politics, forced the abdications of Charles IV and Ferdinand VII, and placed his brother Joseph Bonaparte on the Spanish throne. Much of Spain rose against French rule, combining regular armies, local resistance, and guerrilla warfare.
Portugal was also essential: it served as the principal base for the British army and its Portuguese allies under Arthur Wellesley, later the Duke of Wellington. That is why the war is sometimes described more broadly as an Iberian conflict. However, Spain was the larger central theater of occupation and fighting, making it the standard answer to this quiz question.