At 18 years, 230 days, Yamal became the youngest player to score a hat-trick in La Liga in the 21st century and the youngest to score a hat-trick for Barcelona.
His haul included a brilliant solo effort for his second goal, which saw him beat a player as he cut in from the right wing and curl a shot high into the far corner.
"He's exceptional and he's here to make people happy," Barcelona coach Hansi Flick said. "We need his goals to give him confidence. He's very young and he still has to improve, but everyone knows the quality he has.
"Opponents put two or three players on him and that makes it difficult. Today I'm very happy for him. When he enjoys his football, it's perfect for him and for us."
Yamal said he had struggled to get going earlier in the campaign.
"I didn't feel great (earlier this season)," Yamal told Movistar. "There was the (groin) problem and, generally, I wasn't happy. It was a mix of many things. You could tell.
"I have felt a lot better for a week or so now. I am smiling when I am playing, which wasn't the case for a while, and I am happy on the pitch."
"I'm scoring more goals all the time," he added. "At 16 people already want you to score 100 goals already and it's difficult ... I want to score more as well, but it's not always possible."
Substitute Robert Lewandowski added Barcelona's fourth in stoppage time at Camp Nou.
Second-placed Real Madrid host Getafe on Monday with a chance to trim Barcelona's lead back to one point.
Also on Saturday, Julián Alvarez scored a late winner as Atletico Madrid won at Real Oviedo 1-0 and moved to third place, level on points with Villarreal.
Inaki Williams equalised for Athletic Bilbao in a 1-1 draw at Rayo Vallecano and Real Sociedad defeated Mallorca 1-0.
Only two players have ever registered a hat trick at a younger age, although you have to go back nearly 100 years to find them: José Iraragorri aged 17 years and 337 days in 1930 and Pombo aged 18 years and 200 days 1934.
- with ESPN, AAP