A shareholder agreement is a legally binding contract that outlines the rights, obligations, and responsibilities of shareholders within a company. It sets the rules governing their relationship, decision-making, and ownership percentages.