Pfizer Inc. would cut its yearly tax bill by hundreds of millions of dollars if it buys rival AstraZeneca PLC, but thousands of Pfizer shareholders face a tax hit if a deal goes through.

The blow stems from a little-known provision of U.S. tax rules that is triggered when a U.S. company buys a firm overseas and relocates there to reduce its taxes. Pfizer, as part of its $106 billion bid to buy AstraZeneca, said the combined...