Charles IV of Spain, or to give him his full name, Carlos Antonio Pascual Francisco Javier Juan Nepomuceno José Januario Serafín Diego, was born in November 1748 and was king for 20 years, from 14 December 1778, when his father died, until his abdication in favour of his son Ferdinand on 18 March 1808.
He was the second son of Charles III, the king of Naples and Sicily, but his elder brother Philip suffered from learning difficulties and epilepsy so the throne passed to Charles.
Ruling a country did not come easily to him, as he preferred to spend his time on leisure pursuits such as hunting, so he took a back seat and left matters of estate to his wife, María Luisa, and prime minister, the Count of Floridablanca, until the latter was forced out of office by political opponents and replaced by Pedro Pablo Abarca de Bolea, the Count of Aranda. Following the war against republican France, Aranda was replaced by Manuel de Godoy, a close friend of the king and widely believed to have been the queen's lover.
Those were troubled years, with France first of all declaring war on Spain in 1793, and then entering into an alliance with the country to declare war on Great Britain in 1795. That alliance continued until the Battle of Trafalgar, when Spain decided to ally itself with Britain, but then after Napoleon's victory over Prussia in 1807, under Godoy's guidance, it once again joined forces with France.
As a result of these regular changes, the monarchy and Godoy lost their reputation and there was a growing movement in favour of Charles IV's son Ferdinand, who wanted an alliance with Britain again. Amid an atmosphere of dissatisfaction and unease, the Crown Prince made an unsuccessful attempt to overthrow his father in 1807. By March 1808, after riots and a popular revolt at the Aranjuez palace, Charles IV was under such pressure that he decided to abdicate in favour of Ferdinand, but then regretted it almost immediately and asked Napoleon to help him regain his throne. On 5 May the same year, Napoleon forced both Charles and Ferdinand to abdicate, and appointed his brother, Joseph Bonaparte, as king instead.
This was an unpopular move in Spain, and in 1813, having been kept under guard in France for several years, Ferdinand was restored to the throne, but had to rule under the liberal Constitution of 1812.