In an officially-sanctioned MLB baseball game, there are 9 innings. If the home team is ahead in the top of the ninth and earns 3 outs, the game ends at 8 1/2 innings. If the game is tied after the away team earns 3 outs in the bottom of the ninth, the game goes into extra innings.
Many different baseball leagues play with different rules. In Little League baseball, games go up to only six innings, but can include extra innings in cases of ties. In college baseball, there are only seven innings. Many high schools and colleges want to include more innings in their games so players get a better feel for the professional style of play.