The deal will keep the talented attacker with the Reds until at least 2022.
Longstaff made his first-team debut in December when he led the line in the Carabao Cup quarter-final away at Aston Villa.
Since joining the club in 2015 from Newcastle United, the 19-year-old played mainly as a winger or central midfielder but has regularly taken the centre-forward position in the last 12 months.
A winner of the FA Youth Cup with the U18s in 2019, he stepped up to the U23s side and quickly scored his first goal in the 4-2 win at Southampton back in August.