In simple terms, it goes to the person who sells it to you. However, the process is more complicated as the stock exchanges provide an anonymous matching service known as the order book, where buyers and sellers can buy and sell shares anonymously. When you buy shares, you pay your money to your stock broker, who pays it to the exchange, who pays it to the stockbrokers of the sale of the shares, who pays it to the seller.