Lets begin with one of the definitions of ΔG:
\Delta G = \Delta H - T\Delta S
Recall that:
\Delta H = \Delta U + \Delta (PV), \Delta U = q + w, and w = - \int{P dV} + w_{non-pv}
(wnon-pv represents non pressure-volume sources of work, for example, electrical work)
Combining these expressions, we have:
\Delta G = - \int{PdV} + w_{non-pv} + q + \Delta (PV) - T\Delta S
Assuming constant pressure,
\Delta G = -P\Delta V + w_{non-pv} + q + P\Delta V -T\Delta S = w_{non-pv} + q -T\Delta S
or
q = \Delta G -w_{non-pv} +T\Delta S
Recall the Clausius inequality:
\Delta S \geq \int{\frac{dq}{T}}
Assuming constant temperature, this simplifies to:
\Delta S \geq q/T \Rightarrow q \leq T\Delta S
Therefore,
\Delta G - w_{non-pv} + T\Delta S \leq T\Delta S
or
\Delta G \leq w_{non-pv}
Therefore, for any process at constant temperature and pressure, ΔG can only ever stay the same or decrease in the absence of an external source of work. Because ΔG can never increase under these conditions, any process for which ΔG < 0 is irreversible because reversing the process would require ΔG > 0, which is impossible unless an outside source of work is acting on the system.
As you can see, the derivation here uses both the conservation of energy and the Clausius inequality (a consequence of the second law of thermodynamics), so both principles are at play here.