When a company makes a profit, it is its obligation to return that profit to its shareholders. In the case of a younger company, the company might want to reinvest its profits back into the firm but that is because it hopes to maximize future returns for the shareholders. When the company pays part or all of its profits back to its shareholders, it is called a dividend. The payment does not necessarily need to be from its earnings. If the company pays its shareholders from capital, it is called a liquidating dividend. Another option, the company has is to pay a stock dividend. A stock dividend is when the company pays out shares of stock. This simply increases the number of shares outstanding, so no cash leaves the firm.
So, how does the dividend get paid out, in a world where shares fly from investor to investor continually? According to the third edition of Corporate Finance: Core Principles & Applications, there are four milestones: the declaration date, the ex-dividend date, the record date, and the payment date. On the declaration date, the board of directors declares the payment of dividends. At this point, it sets a record date when you must be on the company’s books as a shareholder to receive the dividend (source). An important fact at this point is that if the company does not receive notification of purchase until after the record date, the purchaser will not receive the dividend. Once the company sets the record date, the stock exchanges or the National Association of Securities Dealers, Inc. fix the ex-dividend date (source). The ex-dividend date is normally set for stocks two business days before the record date. If you purchase a stock on its ex-dividend date or after, you will not receive the dividend payment. Instead, the seller gets the dividend. If you purchase before the ex-dividend date, you get the dividend (source).
So, how is the stock price affected by the dividend? Before the ex-dividend date, the value of the stock will increase by the value of the dividend (minus applicable taxes). After the ex-dividend date, it will fall back to normal levels.
As I implied earlier, younger companies tend to not issue dividends, since they are still working on growing. Mature companies tend to offer dividends more often. Companies that issue dividends use a dividend policy, that helps it decide when to issue dividends and how large the dividends should be. You can try to determine facts regarding the company based upon how the company issues dividends but it does not tend to be as relevant as some investors believe.