Hasmatullah Fazelpur, 23, had in September been sent from Germany to Bulgaria - his first port of call in the European Union and which promptly put him on a plane back to Afghanistan.
But it turned out a German court had issued an emergency injunction prior to the deportation - making the expulsion to Bulgaria illegal. German authorities were therefore ordered to take Fazelpur back.
After the expulsion confusion, Fazelpur finally found himself back in Frankfurt on Thursday.
"He arrived shortly after noon," a member of Pro Asyl, a refugee advocacy group based in Frankfurt, told AFP.
"We are relieved that he is back," said Andreas Linder, a member of another refugee aid group.
Fazelpur was met by authorities and will be transferred to the southwestern city of Tübingen, where he lived for several months before leaving German territory.
Fazelpur's return came as Germany is intensifying its repatriations of Afghans despite protests over whether the conflict-plagued country is safe to return to.
After more than a million asylum seekers arrived in Germany since 2015, Chancellor Angela Merkel's government came under pressure to halt the influx.
With public unease mounting over the new arrivals, Berlin struck deals, including with the Turkish government, to dissuade would-be migrants from trying to reach Germany.
Last year, Berlin signed a deal with Kabul to repatriate Afghans who had failed to obtain asylum, and began expelling people in December 2016.