The foul lines and foul poles are used to demarcate fair territory and, thus, determine what constitutes a foul ball.
Any batted ball that first contacts a fielder while the ball is in foul territory is considered foul. If not touched by a fielder in fair territory, any batted ball that first contacts the field in foul territory beyond first or third base -- with the foul lines and foul poles counting as fair territory -- is considered foul. Batted balls that first contact the field between home plate and first or third base are considered foul if they don't subsequently bounce over or directly contact either base, otherwise pass either base while in fair territory, or ultimately settle at some point in fair territory between home plate and either base.
Batted balls that leave the park on a fly to the left of the left-field foul pole or to the right of the right-field foul pole -- without striking the pole in either case -- are considered foul.
Watch: Mitch Haniger lets a fly ball drop in foul territory, preventing the Astros from scoring on a walk-off sac fly.