Insider trading is the buying or selling of a publicly traded company's stock by someone who has non-public, material information about that stock. It can be illegal or legal depending on when the insider makes the trade. It is illegal when the material information is still non-public. It can be legal as long as it conforms to the rules set forth by the SEC.
The U.S. Securities and Exchange Commission (SEC) defines illegal insider trading as the "buying or selling a security, in breach of a fiduciary duty or other relationship of trust and confidence, on the basis of material, nonpublic information about the security."