The minister had proposed price hikes for a number of medicines in the face of the sharp depreciation of the Iranian rial as a result of Western sanctions imposed over Iran's controversial nuclear programme.
But Ahmadinejad was opposed to the price rises and dismissed the minister.
Although the Western sanctions do not directly target medicines, they make all imports difficult because of restrictions on financial transactions.
Iran manufactures 97 percent of the medicines it uses but many of their ingredients are imported.
In October, an Iranian official acknowledged the price of domestically manufactured medicines had increased by 15-20 percent over the previous three months, and that of imported drugs by 20-80 percent.
Fatemeh Hashemi, head of the Foundation for Special Diseases, sent a letter to UN chief Ban Ki-moon in August asking him to make a case to the West to ease sanctions that are detrimental to patients.
Both the European Union and the United States have imposed tough unilateral sanctions against Iran that go well beyond those imposed by the UN Security Council.
Western governments suspect Iran is seeking to develop a nuclear weapons capability under cover of its civil programme but Tehran insists it is entirely peaceful.
Vahid Dastjerdi's dismissal was swiftly followed by the resignation of Tehran medical faculty chief Bagher Larijani, brother of two of Ahmadinejad's key political opponents. She had fought to keep him in post.
Ali Larijani is speaker of parliament, while Sadeq Larijani is head of the judiciary. Both have criticised the president's policies, including on the economy.
Vahid Dastjerdi was Iran's first woman minister since the Islamic revolution of 1979. A female vice president for the environment did serve during the 1997-2005 presidency of reformist Mohammad Khatami.