Alex Iwobi scored his first Everton goal to send Marco Silva's side into the third-round of the Carabao Cup after a thrilling game at Sincil Bank.
Harry Anderson had put the League One side ahead after just 18 seconds before Lucas Digne equalised with a spectacular free-kick.
Gylfi Sigurdsson put the Premier League side ahead from the penalty spot before a stunning Bruno Andrade volley levelled the scoreline once more.
But late headers from Iwobi and Richarlison avoided embarrassment for the Toffees.