(CNN) - Apple and Qualcomm on Tuesday agreed to dismiss all of the legal battles between the two companies around the world.
The settlement includes an unspecified payment from Apple to chipmaker Qualcomm.
The companies will still work together. Apple and Qualcomm announced a new six-year license contract, with the option to add two more years. It also announced a multi-year chipset supply agreement.
The companies appeared in court on Monday in a trial that was expected to last for four to six weeks in San Diego. Apple CEO Tim Cook was expected to take the stand.
Apple alleged that Qualcomm -- which has made crucial chips for the iPhone -- charged an unfair amount to license its patents to place calls, connect to the internet and for other technologies, including audio and video.
Qualcomm stock soared as much as 22% following the settlement. Apple stock was flat.
Qualcomm said it expects its agreement with Apple to result in an additional $2 per share in incremental earnings as it ramps up product shipments.
"[The settlement is] a bigger deal for Qualcomm because their licensing practices worldwide and market wide could've been affected by an adverse decision by the court," Mark Patterson, a law professor at Fordham University School of Law, told CNN Business. "While Apple might've had a problem if the decision had gone against them, it just would've meant paying more and Apple has a significant cash reserve."
Patterson cautioned that Qualcomm isn't totally in the clear.
"Qualcomm is still being pursued by the Federal Trade Commission and entities in other countries, so their licensing could still be limited," he said.
Qualcomm could have been on the hook for as much as $27 billion in damages for overpaid royalty fees. Qualcomm was seeking over $7 billion in unpaid royalties from Apple and its supplier, as well as other damages totaling billions of dollars.
Over the past two years, the companies have sued one another in courts around the world, and each has seen some victories along the way.
The epic legal battle started in January 2017 when Apple sued Qualcomm for nearly $1 billion. Apple accused Qualcomm of charging "excessive royalties" and withholding payments in retaliation for Apple cooperating with a South Korean investigation into the chipmaker.
The companies also sued each other in several other patent disputes. For example, in one case, Qualcomm asked a US federal judge to ban the sale of iPhones.
CNN's Ahiza Garcia contributed to this article.
The-CNN-Wire ™ & © 2019 Cable News Network, Inc., a Time Warner Company. All rights reserved.