This is a bit "Janet and John", but as I understand it from the best single volume study of the war at my disposal at the moment ...
The “de jure” government of Spain (1808)
In 1808 Spain was ruled by Carlos IV. Carlos had discussed and agreed with Godoy, and other advisors, that he should flee to America by way of Seville although Esdaile does not state the actual destination, see p 31. Some time later, Carlos IV was persuaded to abdicate in favour of Fernando VII. These were both absolutist monarchies (there was no Cortes at this time in Spain).
Ferdinand VII was welcomed enthusiastically (as monarch) to Madrid on 24th March. But Murat had arrived the day before – and he refused to recognise Ferdinand as rightful ruler. Carlos, Maria Luisa and Ferdinand were summoned to meet with Napoleon at Bayonne (Godoy meantime being rescued from captivity and was "whisked away" to safety in France – his intrigues had previously proved quite useful to Napoleon). When Napoleon had all four birds in his hand he demanded the throne of Spain be handed over – “in exchange for generous pensions for the royal family and guarantees for territorial and religious integrity for Spain itself” see Esdaile p 34 / 5
So, the throne of Spain had been signed over, by both of the persons who seemingly had some form of “rightful” claim to it – under Spanish law as it existed at the time. Prior to this occurrence, surely Ferdinand VII, and if not him, Carlos IV, was the head of a legal, legitimate government of Spain. They were recognised as such by Spain itself and all other nations, it would seem, with the exception of France.
The "de facto" government of Spain 1808-13
Napoleon’s imposition of Joseph as King, French generals as military advisors, French military governments (at regional and local level, enforced by military occupation) would appear, from May 1808 onwards, to be a “de facto” government – in that Napoleon, via Joseph, was in possession of both the authority and control of the state. But this is not to say that this rule was unpoopsed - quite the contrary. Despite the removal of Ferdinand VII (and Carlos IV) Joseph was never accepted, by the majority of Spanish, as rightful ruler of Spain. Moreover, there was a very clear shift in the power base from Madrid to more autonomous Spanish regions under control of Juntas and demands for the imposition of a Cortes (elected, legislative assembly).
The relatively limited extent of both: 1) popular representation to (or “franchise”), and 2) required credentials for holding office in, the regional Juntas and proposed Cortes are not at issue here. Suffice to say that between 1808 and 1814 there were a number of developments within Spain – including the drafting of a Constitution – which Ferdinand was presented with on his return to Spain with demands that he sign it before he would be accepted once more as ruler.
Suffice to say that eventually the demands / assertions of the Cortes were declared null and void and by 10-11th May (1814) Ferdinand was restored as absolutist ruler of Spain. pp 497-99
Esdaile, C, 2002, the Peninsular War: a New History
I will be reading other material in the New year including Lovett so would be able to provide a bit more balanced analysis then
Best wishes
Anthony