Bangalore - Afghanistan clawed their way back after India's Shikhar Dhawan hit a blazing century on Thursday as the minnows capped their astonishing rise from war and refugee camps to joining the sport's elite.
Test cricket's newest team were on the receiving end of some aggressive batting as Dhawan, who smashed 107, and Murali Vijay, who made 105, put on a 168-run opening stand after the hosts elected to bat first in Bangalore.
But the Afghan bowlers struck back with four wickets in the final session as the hosts slipped from 280-1 to 347 for six at stumps at Bangalore's M Chinnaswamy Stadium.
Fast bowler Yamin Ahmadzai, who gave Afghanistan their first Test scalp after getting Dhawan out early in the second session, led the attack with two wickets.
Hardik Pandya, on 10, and Ravichandran Ashwin, on 7, were at the crease when play ended after an extended final session but only 78 overs were possible due to two rain interruptions.
Afghan skipper Asghar Stanikzai called it a "very proud moment" as he strode onto the field for the toss with opposite number Ajinkya Rahane.
"All the guys have first-class experience. Inshallah (God willing), we can do well," the 30-year-old batsman said.
Afghanistan have become one of only 12 nations sanctioned to play Tests, the five-day format considered cricket's peak, after defying heavy odds to emerge as a force in the game.
But soon the rookies realised they were up against the world's top Test side as Dhawan galloped to his century in just 87 deliveries, becoming the first Indian batsman to reach three figures on the opening day before lunch.
Dhawan hit 19 fours and three sixes as he set about the Afghan bowlers including spin sensation Rashid Khan, smashing three boundaries in the teenager's opening over to bring up his 50.
Vijay then took control after Dhawan's departure, putting together a 112-run second-wicket partnership with Lokesh Rahul who made 54.
Ahmadzai bowled Rahul, who dragged a delivery on to his stumps, and Wafadar trapped Vijay lbw to lift Afghan spirits.
Khan, who gave away 120 runs in 26 overs, then combined with fellow spinner Mujeeb Ur Rahman as the pair got a wicket each of Rahane and Cheteshwar Pujara to pull things back.
Most cricket-loving Afghans were watching the match on TV back home as they prepared for a three-day public holiday marking the Muslim festival of Eid.
Afghans took to social media to celebrate the start of the Test, which comes amid a government ceasefire during the holy month of Ramadan.
"As a cricket fan I salute you all for bringing Afghanistan great pride," Jamal Sahar Kanwal from the eastern city of Jalalabad wrote on Facebook.
Earlier, Afghan President Ashraf Ghani sent his congratulations for what he called a "historic day".
"I am proud of the men who championed cricket in Afghanistan in the dawn of the century and believed in themselves that one day Afghanistan will play against the best in the world," he said.
Indian Prime Minister Narendra Modi tweeted: "May sports continue to bring our people closer and strengthen ties."
Afghan cricket grew out of refugee camps in Pakistan where many families were based after they fled conflict in the 1980s and 1990s.
The national team have made giant strides against much richer and more stable countries, despite unrest at home which has forced them to train in India since 2015.
Afghanistan last year achieved full member status of the International Cricket Council, making them one of only 12 Test teams.
They gained one-day international status in 2009 and have qualified for their second 50-over World Cup to be held in England and Wales next year.
Afghanistan have also been part of four Twenty20 World Cups.
Last week they secured a T20 series sweep over Bangladesh helped by spin bowler Khan, 19, the stand-out star of this year's Indian Premier League.
"The terror in our home area meant we did not have access to an education while growing up. My parents even forbid my siblings and I to play cricket outside our home," Khan, one of 12 children, said in a recent interview with Afghan media.
"But no amount of war stopped me from sneaking out to play cricket with my brothers."
Only last month, an attack on a cricket match in Khan's home city of Jalalabad killed eight people and wounded 45.
While Afghanistan's successes so far have come in short formats of cricket, they must now prove they can stand the physical and mental challenge of a five-day match.