The forward, who has now scored 210 goals in 217 games under Guardiola, scored two penalties as Barcelona humbled their Catalan rivals.
The records continue to tumble for the Argentine, who now has 72 goals in all competitions in what has been a phenomenal campaign.
He also netted a sublime low finish into the far corner following a thrilling breakaway.
After scoring his fourth, the World Player of the Year ran to the touchline and hugged Guardiola as the rest of the squad gathered to join them in a huddle.
Liga champions Real Madrid came from behind to win 2-1 at Granada while Jonas scored in added time to give Valencia a 1-0 home win over regional rivals Villarreal that secured them third place and the last automatic qualifying berth in the Champions League for the third year in a row.
Valencia have 61 points and Malaga are fourth on 55 after falling 2-1 at Europa League finalists Atletico Madrid who closed to within two points in fifth.