Each political group in the European parliament – the centre-left socialists, the centre-right European People’s Party (EPP), the liberals, greens etc, propose a lead candidate. In theory, the candidate from the group that comes top becomes the president.
But this system isn’t written into the treaties, and has only been used once in 2014 – it’s not clear whether it will survive. Member states don’t like it because it takes power away from them and gives it to the parliament, and they’re under no legal obligation to follow it.