This is the individual segment of a baseball game, of which there are nine in a Major League Baseball game. An inning is separated into halves, the top and bottom. The time between each half inning is called the middle of the inning. During the top half, Team A attempts to score runs on Team B, while Team B attempts to prevent it. During the bottom half, Team B attempts to score runs on Team A, while Team A attempts to prevent it. A half-inning is over when the defense gets three outs against the offense.
It is standard practice that the home team bats last, therefore the away team bats at the top of every inning. They would be Team A in the example referenced above. If the home team is ahead after the top of the ninth inning has concluded, the game ends immediately. There are no time limits on innings, and in professional baseball, a game tied at the end of nine innings goes into extra innings, in which full innings are played, one at a time, until one team comes out ahead.