An inning, or innings, is a fixed-length segment in a game of baseball during which one team attempts to score while the other team attempts to prevent the first from scoring.
In many other sports, the length of the game is dictated by a clock and teams swap offensive and defensive roles dynamically by taking possession of a ball or similar item. In baseball (and cricket), however, one team, said to be "batting", attempts to score "runs"—see run—while the other team, said to be "fielding", attempts to prevent the scoring of runs and get members of the batting team out. The teams switch places after the fielding team has succeeded in getting three players out, making a clock unnecessary.
In cricket, the term innings is also used to refer to the play of one particular player (Smith had a poor innings, scoring only 12). By extension, this term can be used in British English for almost any activity which takes a period of time (The Liberal government had a good innings, but finally lost office in 1972, or You've had a fair innings, now it's my turn, meaning "you have spoken for long enough, now let me speak"). It is also used in reference to someone who has died at a reasonably old age or lived a rich and rewarding life (Ah, well. John was 83. At least he had a good innings.). The baseball-derived parallel to this in American English is the term at bat.
The term inning has been used in English since at least 1735; source: Merriam-Webster's Collegiate Dictionary. As cricket was a mature, highly organized sport in the 1600s in England (source: Wikipedia), the term's origin could well precede 1735.
An inning in baseball consists of two halves. In each half, one team bats until three outs are made, with the other team playing defense. Each half-inning formally starts when the umpire calls "Batter up!" A full inning consists of six outs, three for each team; and a regulation game in Major League Baseball consists of nine innings. At other levels, such as many high school games, seven innings are standard, and seven innings is also standard for some Minor League Baseball games when playing a double-header. The visiting team always bats first in each inning, and the visitors' turn at bat is often called the top of the inning, derived from the position of the visiting team at the top line of a baseball line score. The home team's half of an inning is also called the bottom of the inning, and the break between halves of an inning is called the middle of the inning. If the home team is leading in the middle of the ninth inning, or scores to take the lead in the bottom of the ninth inning, the game immediately ends in a home victory. Ending a half-inning is referred to as "retiring the side." A half-inning in which all batters are put out without taking a base is referred to as a "one-two-three inning."
If the score is tied after after the regulation number of innings, the game goes into extra innings until an inning ends with one team ahead of the other. In Japanese baseball, however, games end if tied after 12 innings. As in the case of the ninth inning, a home team which scores to take a lead in any extra inning automatically wins, and the inning (and the game) is considered complete at that moment regardless of the number of outs. This is commonly referred to as a "walk-off" situation, since the last play results in the teams walking off the field because the game is over.
In US English, this baseball-originated terminology is sometimes found in non-sports usage in a tense situation: "it's the bottom of the ninth with the home team behind," meaning "there isn't much time to turn things around here."