Most stock exchanges work according to the forces of supply and demand, which determine the prices at which stocks are bought and sold. This means that no trade can occur until one participant is willing to sell the stock at a price at which another is willing to buy it, or until an equilibrium is reached. If there are more buyers than sellers, the stock's price will rise due to increased demand. On the other hand, if more people are selling a stock, its price will decrease.
During a regular trading day, the balance between supply and demand fluctuates as the attractiveness of the stock's price increases and decreases. These fluctuations are also why closing and opening prices are not always identical. In the hours between the closing bell and the following trading day's opening bell, a number of factors can affect the attractiveness of a particular stock.
For example, good news such as a positive earnings announcement may be issued, increasing a stock's demand and raising the price from the previous day's close. Conversely, bad news can negatively affect price with less demand for the shares.
Along with good and bad news, the development of after-hours trading (AHT) has had a major effect on the price of the stock between the closing and opening bells. AHT used to be restricted to institutional investors and high-net-worth individuals; however, with the development of electronic communication networks (ECNs), AHT is now available to average investors. With wider spreads and liquidity than what is seen during the day, AHT creates greater volatility in a stock's price.
For more info on stock trading, read "Investing 101: A Tutorial for Beginner Investors."