Form a new corporation. A lawyer will typically also organize the corporation, which involves issuing shares, electing directors and officers and making other organizational resolutions.
A shareholders agreement (stockholders agreement in the US) is an agreement between a company’s shareholders. A shareholders agreement commonly deals with the management of a company, restrictions on the sale of shares, the right to receive dividends and what happens on the death of a shareholder.
A partnership agreement is an agreement between partners which commonly deals with the management of the partnership, contributions of partners, right to receive profits and the dissolution of the partnership.
The purchase or sale of a business can occur through a share of a business' assets or its shares. Typically, agreements need to be drafted, due diligence conducted and closing documents prepared.