Yamal gave Barca a two-goal lead with strikes in the 30th and 37th minutes while Dani Olmo extended their advantage right after the break with a first-time effort from close range.
Pedri scored the fourth with a tap-in in the 64th minute while Girona substitute Cristhian Stuani netted a consolation goal in the 80th, six minutes before Barca were reduced to 10 men when forward Ferran Torres was given a straight red card for a nasty studs-up challenge on Yaser Asprilla.
Barcelona top the LaLiga standings with 15 points, four ahead Real Madrid and Villarreal. Girona are seventh on seven points.