Carlos III (of Spain) was Duke of Parma and king of Naples before his elder half-brother Fernando VI became king of Spain.
His son Fernando I became king of Naples before his elder brother became Carlos IV of Spain.
In today's world, unless one is the heir -- and a direct heir at that -- he doesn't really stand much of a chance of inheriting the throne. We have observed how those close in the British royal succession, since the 20th century, have been displaced (it's hard to believe that at one point, the Princess Royal was second in line to the throne; the same could be said of her aunt Margaret). Prince Harry was born 3rd in line, but is now 6th.
But in the past, poor medicine and high death rates oftentimes brought those born remote or indirect in the succession close to thrones. Queen Victoria, for instance, was born only 5th in line, yet still succeeded. King George V was born 3rd in line, as the second son of the Prince of Wales -- just like Harry -- yet still succeeded.
Otherwise, fluke factors would account for the succession of dynasts who expected to be displaced, but unexpectedly came to acquire thrones. Interestingly enough, the present Queen Elizabeth II was also born third in the royal succession, just like her grandfather. As it was, the abdication of her uncle brought her family to the throne.
Yet, there was another way for second sons or indirect heirs to acquire thrones: branching out. We have seen how cadets of the Habsburgs, Bourbons, Coburgs, and Glücksburgs acquired foreign thrones. with considerable success. Others, like the Hohenzollerns and Wittelsbachs, were less successful.
Anyhow, bearing all this in mind, I wanted to come up with a list of second sons who managed to acquire thrones before first sons, excluding cases where the second sons succeeded because their older brothers died and vacated their positions as direct heirs (e.g. the engaged but not married Duke of Clarence died of influenza in 1892, whereupon his younger brother assumed his place as second in line to the British throne).
Here are some examples in recent centuries: 1) Prince Otto of Bavaria, second son of King Ludwig I, who in 1832 got elected as king of Greece. His older brother, the crown prince, succeed to the Bavarian throne as King Maximilian II upon the abdication in 1848 of their father.
2) Speaking of Greece, after the house of Wittelsbach got deposed, it was replaced by the house of Glücksburg, when Prince William of Denmark (second son of King Christian IX) got elected as King George I of the Hellenes. This was in 1863, 43 years before his older brother, "The Eternal Crown Prince", finally succeeded to the Danish throne as King Frederik VIII.
3) In fact, even a son of the said "Eternal Crown Prince" acquired a throne before his own father: Prince Carl of Denmark got elected as King Haakon VII of Norway in 1905, a year before the death of his grandfather and the accession of his father to the Danish throne. The said father would reign for only six years, so the man we know in history as King Christian X of Denmark didn't have to wait too long to succeed; but nothing changes the fact that his younger brother acquired a throne before he himself did.
4) Due to the conditional renunciation of his succession rights to the German duchy of Saxe-Coburg and Gotha, the man we know in history as King Edward VII of Great Britain was preceded by a younger brother, the Duke of Edinburgh, in acquiring a throne. Later on, a nephew through another younger brother (the Duke of Albany) would sit on that throne before he himself finally became the reigining British monarch.
Can anybody fill me in on other examples, such as potential cases involving the houses of Bourbon and Habsburg?