A massive $150 billion merger between Pfizer and Allergan has been called off after the Obama administration issued new rules designed to crack down on corporate tax avoidance.

The pharmaceutical tie-up was designed to allow New York-based Pfizer (PFE) to move its corporate headquarters to Ireland, and possibly reduce its tax bill. If completed, it would have been the second-largest merger in history.

The takeover was an example of an "inversion," a maneuver by which a U.S. multinational merges with a foreign company and changes its legal tax residence to another country with a lower tax rate.

New rules issued by the U.S. Treasury on Monday seek to discourage inversions. They change how the ownership percentage of the foreign company is calculated and crack down on a tax strategy called "earnings stripping."

Related: New crackdown on corporate tax avoidance

Pfizer explicitly said that the new rules are the reason it and Allergan were scrapping the merger plans.

Investors had already assumed the deal would be derailed by the Treasury action. They sent Allergan (AGN) shares down by 15% during Monday trading. Allergan shares were slightly lower in premarket trading Wednesday following the announcement, while Pfizer (PFE) shares were slightly higher.

It's the second time in recent years that Pfizer has been left at the altar. In 2014, it tried unsuccessfully to acquire British drug maker AstraZeneca (AZN) and it didn't hide the fact that tax savings were one of the main drivers.

Pfizer said it will now look at other methods to try to help boost its share price, including possibly separating parts of its company from one another. It said it will make a decision on its move by the end of this year.

President Obama lauded the new Treasury rules on Tuesday, saying that existing laws are "poorly designed."

Legal loopholes in the tax code can "come at the expense of middle class families because that lost revenue has to be made up somewhere," Obama said. "It means that we're not investing as much as we should in schools, in making college more affordable, in putting people back to work, in rebuilding our roads, our bridges, our infrastructure, creating more opportunities for our children."

-- Jeanne Sahadi and Alanna Petroff contributed reporting.

Correction: An earlier version of this story misstated the value of the planned deal.