AbbVie Inc. agreed to buy Allergan PLC for about $63 billion in a bet by the two drugmakers that a combination will deliver new sources of growth that they have struggled to find on their own.

The takeover is worth about $188 a share in cash and stock, the companies said. The price represents a 45% premium over Allergan’s closing share price Monday of $129.57. If not for a surge in the shares in recent days on expectations for a breakup of the company, the premium would be even bigger.

Buying...