SAN FRANCISCO — Uber on Monday settled a long-running legal battle with drivers in California and Massachusetts who wanted the ride-hailing company to recognize them as employees, agreeing to pay the drivers $20 million but not changing their status as independent contractors.

As part of the settlement, Uber said, it will also change the way it removes drivers from the service by making the process more transparent. It published a policy that describes how it deactivates drivers and said it would institute an appeals mechanism, as well as classes to teach drivers how to improve ride quality.

The settlement defuses a potentially thorny issue as Uber prepares to go public. Uber, which confidentially filed for an initial public offering in December, is expected to be one of the largest tech offerings in recent years and could be valued at as much as $120 billion. In a move intended to appease drivers and acknowledge their role in building the company, Uber plans to offer them the chance to buy shares at its I.P.O.