He goes up to one guard and asks " If I ask the other guard which door leads too freedom, what will he say?" he then goes into the opposite door.
So if he asks the lying guard the guard, the guard would say the prison door, because he lies. But if he asks the truthful guard, knowing his companion would lie, points to the prison door.