The attack in the eastern city of Jalalabad killed 33 people yesterday and wounded more than 100, the first such incident in Afghanistan for which IS has claimed responsibility.
President Ashraf Ghani's arrival on a two-day visit was announced by Iran's official IRNA news agency.
State television showed him and his Iranian counterpart Hassan Rouhani at Saadabad Palace in Tehran where top-level dignitaries are often welcomed.
Ghani, elected in September, was accompanied on the trip by his foreign minister and minister for oil and mines.
More From This Section
Yesterday's attack outside a state-run bank in Jalalabad was the worst to hit Afghanistan since November, mostly killing government officials who were drawing their salaries.
A person purporting to be an IS spokesman said in a call to AFP that the group was behind the bombing. An online posting allegedly from IS made the same claim, which could not be verified.
Iran and Afghanistan have close ties. In 2001, Tehran took the rare step of cooperating with Washington in a US-led invasion that ousted the Taliban regime from power in Kabul.
Iran has been central in the Baghdad government's fightback against IS, coordinating Shiite militias and providing military advisers from its powerful Revolutionary Guards Corps.