Lula da Silva, who was jailed four years ago on corruption charges, has defeated far-right President Jair Bolsonaro.