When generic- and branded-drug companies settle patent disputes, it's easy to tell who had the upper hand -- just look at how early the generic can be launched relative to the patent expiration.

It appears that Cubist Pharmaceuticals (Nasdaq: CBST) had a strong hand in its negotiations with Teva Pharmaceutical (Nasdaq: TEVA). The two negotiated a settlement in which Teva can't launch a generic version of Cubist's antibiotic Cubicin until Dec. 24, 2017. Cubist is giving up 21 months of competition-free sales, but that's a reasonable trade for not having to risk its patents being invalidated in court. Cubicin is the company's only product, so seeing generic competition now would be very costly.

Cubist even worked in a few trinkets that make the deal look better. If Cubist is able to get a pediatric extension, which would extend the normal exclusivity period by six months, Teva's launch date is also extended by six months.

Teva will buy its U.S. supply of Cubicin ingredients from Cubist, which gives Cubist an opportunity to make money through the sale of the goods and by taking a cut of Teva's net profit. The company didn't disclose the numbers, so it's a little hard to know whether this is a good deal or a great one.

Investors seemed content enough with the deal. Cubist's shares are up 15% today.

Part of the increase is likely because investors hate unknowns. The risk of losing Cubicin sales has been hanging over Cubist's head for more than two years. The same type of uncertainty plagues Momenta Pharmaceuticals (Nasdaq: MNTA) as it waits to see if Teva will get its generic version of sanofi-aventis' (NYSE: SNY) Lovenox approved. Even large companies like Merck (NYSE: MRK) aren't immune to it.

With the patent fight settled, Cubist can get back to focusing on its pipeline. Settlement or not, generic competition comes to all drugs eventually.

Follow Cubist as it moves toward its next drug approval. Click here to add it to My Watchlist, which will help you keep track of all our Foolish analysis on Cubist.