The Infield Fly Rule in baseball (specifically, rule 6.05e, coupled with the definition in rule section 2.00) is intended to prevent unfair gamesmanship by the fielders that would result in an easy double play or triple play.
The infield fly rule applies only when there are fewer than two outs, and there is a force play at third (runners on first and second base, or bases loaded). In these situations, if a fair fly ball is hit that, in the umpire's judgment, is catchable by an infielder with ordinary effort, the batter is out regardless of whether the ball is actually caught in flight. The rule states that the umpire is supposed to announce, "Infield fly, if fair." If the ball will be almost certainly fair, the umpire will likely yell, "Infield fly, batter's out!" or just "Batter's out!" Umpires also typically raise one arm straight up to signal to everyone that the rule is in effect.
Any fair fly ball that could have been caught by an infielder with ordinary effort is covered by the rule regardless of where the ball is caught. The ball need not be caught by an infielder, nor must it be caught in the infield. For example, if an infielder retreats to the outfield in an effort to catch a fly ball with ordinary effort, the Infield Fly Rule would be invoked, even if an outfielder ultimately caught the ball, and even if no infielder attempted to make a play on the ball. Similarly, a fly ball within the infield that could have been caught by an infielder with ordinary effort, but is caught by an outfielder, would also be covered by the rule.