The attack took place in the south-eastern Kerman province on Sunday.
The suspect was arrested by police as he attempted to leave the province on Sunday evening.
"An Afghan national killed ten people due to personal differences in Rafsanjan," Hossein Rezai, acting governor of Kerman, told state news agency Irna.
Six Afghans and four Iranians were killed in the attack, he said. One person was wounded.
Iran has hosted millions of Afghan refugees for decades, but more have crossed the 900-kilometre border between the countries since the Taliban seized power in Afghanistan last year.