LONDON – The drug company Perrigo agreed on Monday to acquire the Irish biotechnology company Elan in a cash-and-stock deal worth $6.7 billion.

The announcement comes after months of uncertainty over the fate of Elan, the subject of a prolonged takeover effort by Royalty Pharma. In June, Elan said it had put itself up for sale, and the deal with Perrigo, based in Allegan, Mich., is the culmination of that effort.

Under the terms of the deal, Perrigo said it would offer $16.50 in cash and shares to Elan’s shareholders, 11 percent above Elan’s closing share price in New York on Friday. Including Elan’s existing cash, the deal is worth a combined $8.6 billion.

As part of the takeover, Perrigo also said it would reincorporate the combined company in Ireland, where the country’s corporate tax rate is 12.5 percent. Perrigo added that the move would lead to unspecified savings, as the company took advantage of Ireland’s lower tax rate.

The reduced corporate tax rate in Ireland has led a number of United States companies to create offices there. Apple, for example, confirmed earlier this year that two of its Irish subsidiaries paid approximately 2 percent of their earnings in tax because of an agreement worked out with local tax authorities.

Perrigo, which manufacturers over-the-counter and generic drugs, said the acquisition of Elan would allow it to expand internationally and gain access to Elan’s stable of pharmaceuticals, including the multiple sclerosis drug Tysabri.

“Through this transaction, Perrigo establishes a diversified platform for further international expansion,” the company’s chief executive, Joseph C. Papa, said in a statement.

Perrigo said it expected around $150 million of annual operating and tax savings from the deal, which would be financed in part through a $4.35 billion loan from Barclays and HSBC. The combined company will be listed on the New York Stock Exchange and the Tel Aviv Stock Exchange.

In the takeover, which has been approved by the boards of both companies, Elan’s shareholders will receive $6.25 in cash and 0.076 of a Perrigo share for each of their Elan shares. The deal will give Perrigo’s shareholders 71 percent of the new the company, while Elan’s investors will own the remainder, according to a company statement.

Shares in Elan rose 9.5 percent in morning trading in Dublin on Monday.

The deal, which is expected to close by the end of the year, comes after a fourth-month effort by Royalty Pharma to buy Elan. Royalty Pharma, which specializes in collecting royalties from existing drugs, eventually dropped its bid in June after a $6.7 billion offer was rejected.

Citigroup, Morgan Stanley, Davy and Ondra Partners advised Elan on the deal, while Barclays advised Perrigo.