Alfonso XIII, born posthumously in 1886, became king after his father Alfonso XII died, with his mother María Cristina serving as regent until his 16th birthday in 1902. His reign was marked by instability due to the loss of colonies in 1898, the war in North Africa, and uprisings in Barcelona, leading to a coup by Primo de Rivera, who ruled as dictator from 1923 to 1930. Ultimately, Alfonso XIII was forced to abdicate when the Republicans won the 1931 elections, resulting in the proclamation of the Second Republic and his subsequent exile.