AstraZeneca (AZN) agreed on Thursday to buy Bristol-Myers Squibb’s (BMY) stake in their diabetes joint venture for up to $4.1 billion.

The London-based biopharmaceutical giant will initially pay $2.7 billion for the stake, in addition to regulatory, launch and sales payments amounting to as much as $1.4 billion. It will also pay Bristol sales-related royalty payments until 2025.

AstraZeneca may make another $225 million payment once certain assets are transferred.

The deal gives the company intellectual property and global rights for the development, manufacture and commercialization of the business.

The diabetes partnership expanded last year when Bristol acquired Amylin Pharmaceuticals for $5.3 billion and subsequently added the firm to the joint venture. AstraZeneca paid $3.4 billion for a 50% share of Amylin’s products. The companies then combined their marketing teams for diabetes drugs earlier this year.

However, sales at the diabetes venture have underwhelmed Wall Street analysts, and Bristol announced last month that it would stop its own efforts to develop new diabetes drugs.

Through the first nine months of this year, AstraZeneca reported $546 million in sales related to the  venture’s four main products. Bristol logged sales of $1.2 billion.

Last week, an advisory panel recommended that the U.S. Food and Drug Administration approve dapagliflozin, an experimental treatment for Type 2 diabetes. A similar treatment from Johnson & Johnson (JNJ) was approved in March, while Eli Lilly (LLY) is also developing a version.

Drug developers like Bristol and AstraZeneca have shed jobs in anticipation of lost sales from generic competition, as patents protecting certain drugs’ exclusivity expire.

Bristol has cut about a third of its employees and half of its manufacturing plants. In March, AstraZeneca announced worldwide cuts of about 2,300 employees.

Shares of AstraZeneca rose 41 cents to $59.25 early Thursday morning. Bristol was up 74 cents, or 1.4%, at $53.33.

Follow Matthew Rocco on Twitter @MatthewRocco