Sunil Chhetri opened the scoring for the hosts, while Zubayr Amiri equalized.
Samad hit the winner after Sunil Chhetri’s 86th-minute free-kick had been cancelled out by a Zubayr Amiri header two minutes later in a frantic finish at the Vivekananda Yuba Bharati Krirangan Stadium and India are now level at the top of Group D with Hong Kong with one game remaining.
A full-blooded opening in front of an enthusiastic crowd delivered little in the way of clear-cut chances during the first quarter of the game, with Manvir Singh seeing his attempt blocked and Liston Colaco firing his free-kick well over the bar.
Indian defender Jeakson Singh Thounaojam went closest to breaking the deadlock when he powered a header over the bar after a perfectly flighted 16th-minute corner from Roshan Singh Naorem.
Roshan then forced Faisal Hamidi to make a sharp save at his near post with a cheeky attempt from wide on the right eight minutes before the break.
Chhetri set himself up for an acrobatic attempt in the dying seconds of the half only to see his effort blocked by Haroon Amiri four minutes after the restart the 37-year-old was off target with a close-range header while under pressure from the Afghan defence.
Ahmad Haydary squandered a rare chance for Afghanistan in the 64th minute when he steered his header outside Gurpreet Singh’s left post and at the other end, Muhammad Ashique Kuruniyan smashed his long-range attempt narrowly wide.
Gurpreet was called into action 16 minutes from time to deny Amiri when the substitute’s flying volley was kept out by the Indian goalkeeper when he dropped to his right.
The action continued to move from one end to the other as both teams grew increasingly desperate to claim a much-needed winner with Fernandes shooting high over the goal before Chhetri finally put India in front when he slammed his free-kick home.
But Afghanistan refused to yield and Amiri headed past Gurpreet to level the scores two minutes later, only for Sahal to fire his right-foot shot into the bottom corner to seal a remarkable win for India.