With current leaders Real Madrid thrashing Osasuna 4-0 on Saturday, Barca needed a maximum haul against the strugglers to move to within one point of Los Blancos and overtake second-placed surprise package Girona.
Due to Robert Lewandowski's ankle sprain, Yamal kept his place in the starting lineup on the right-wing, with Joao Felix on the left and Ferran Torres operating through the middle for the champions.
The Blaugrana came into Sunday evening's showdown still unbeaten on all fronts this term, but that record was in jeopardy with less than a minute gone, as Lucas Boye slipped through Bryan Zaragoza to fire a low effort underneath Marc-Andre ter Stegen's arm.
Zaragoza's 17th-second effort marked the earliest La Liga goal that Barca had conceded in the 21st century, and things soon went from bad to worse for the Blaugrana, as Zaragoza doubled his tally in style with 29 minutes gone.
Gerard Gumbau received the ball on the half turn inside his own half and released Zaragoza, who skilfully evaded Jules Kounde and sat Ter Stegen down before finding the roof of the net with aplomb.
Kounde was then forced off to add insult to injury for Barcelona, but Yamal sparked a fightback on the stroke of half time, meeting Felix's ball to the back post for a simple tap-in.
By prodding the ball home from less than a yard out, Yamal became the youngest-ever player to net a goal in Spain's top flight, beating the previous record by a mere 11 days.
Former Malaga and current Botosani attacker Fabrice Olinga was 16 years and 98 days old when he scored for the former club in 2012, but the Cameroonian has now been dethroned after holding the record for 11 years.
Sunday's goal was just one of a plethora of records Yamal has already left in his wake during his fledgling career, having become Barcelona's youngest player on his debut in April as a 15-year-old.
The 2007-born attacker also became the youngest man to ever play and score for Spain in a 7-1 Euro 2024 qualifying thrashing of Georgia last month, and two assists against Villarreal made him the youngest player to register a La Liga goal contribution in August
Last week, Yamal also set the record for the youngest player to make a Champions League starting lineup in Barca's 1-0 win over Porto, not long after he signed a new three-year deal with a €1bn (£864.6m) release clause.
Yamal's historic strike came at the perfect time for Barca, who eventually levelled matters in the 85th minute, as a close-range Sergi Roberto shot struck goalkeeper Andre Ferreira and trickled over the line.
Barca's 2-2 draw with Granada leaves the La Liga champions third in the table heading into the international break, where Yamal will represent Spain in Euro 2024 qualifying fixtures with Scotland and Norway.