Ask any guard, "if I ask the other guard which door is the door to freedom, which one will they indicate?" and then choose the other door.
Explanation:
If you ask this question to the liar, then the other guard would point out the correct door (as he is the truthful one), but the liar would lie and point you to the other door, so choosing the opposite of what the guard indicated would gain your freedom.
If you ask this question to the truthful guard, then the other guard would point to the wrong door (as he is the liar), the truthful guard would point you to the door that the liar indicated (which is the wrong door), so choosing the opposite of what the guard indicated would gain your freedom.