Abstract Starting from a microscopic system-baths description, we derive the general conditions for a time-local quantum master equation (QME) to satisfy the first and second laws of thermodynamics at the fluctuating level. Using counting statistics, we show that the fluctuating second law can be rephrased as a generalized quantum detailed balance condition (GQDB), i.e., a symmetry of the time-local generators which ensures the validity of the fluctuation theorem.