TEHRAN — The increasingly bitter feud between Iran’s president and hard-line commanders and clerics exploded into the open over the weekend with the arrest of a top environmental official and the prison death of a prominent Iranian-Canadian environmental activist who was arrested last month.

The official, Kaveh Madani, the deputy head of the Department of the Environment, was arrested on Saturday, interrogated, and apparently released on Monday by intelligence agents affiliated with the Islamic Revolutionary Guards Corps. His department posted an image of him on Twitter during a meeting on Monday with the German ambassador to Iran, Michael Klor-Berchtold.

The arrest of Mr. Madani, 36, an American-educated academic on leave from London’s Imperial College, was particularly embarrassing for President Hassan Rouhani, who had recruited him as a sign the country is ready to welcome back expatriate Iranians.

It was consistent with a series of actions taken by hard-line groups in recent months to publicly humiliate and undermine Mr. Rouhani, analysts say. They are accused of instigating the protests that shook the government around the New Year in an effort to show that Mr. Rouhani’s promises of economic growth were failing. That backfired when the protests spread to 80 cities and anger quickly turned against the Islamic establishment.