The Turkish midfielder will join the Reds on a season-long loan once he passes a medical at Anfield.
Sahin, 23, is seen as surplus to requirements by Jose Mourinho at the Bernabeu and the battle for his signature has been fought out mainly between Liverpool and Arsenal.
The Gunners were thought to be leading the race to sign the playmaker but Liverpool are the ones who have secured the signing.
Sahin joined Madrid last summer after being named as the Bundesliga's player of the season with Borussia Dortmund but he failed to tie down a starting place last season.
He has 31 caps for Turkey and became their youngest ever scorer when he netted on his debut against Germany in 2005, aged 17.