Biotech firm Gilead Sciences (GILD -2.70%) and pharmaceutical company Teva Pharmacaeutical (TEVA 1.85%) have agreed to settle an ongoing lawsuit regarding Gilead's patents of HIV and hepatitis B medication Viread.

A trial had been scheduled to begin Wednesday, with the settlement on Tuesday avoiding that if the agreement between the two is finalized. The agreement will allow Teva to market a generic version of Viread beginning in December 2017.

Gilead first sued Teva in 2008 over alleged infringement concerning four of its patents, doing so once again in 2010 in what became a lengthy legal fight. Viread pulled in $849 million in sales last year for Gilead, making the case an important one for its revenue.

Gilead President and Chief Operating Officer Dr. John Milligan commented on the agreement in his company's release, saying, "This settlement ... removes some uncertainty and minimizes further distraction and investment of human and financial resources associated with this litigation."

link