The aim of the present work is to investigate the role of coherent structures in the generation of the secondary flow in a turbulent square duct. The coherent structures are defined as connected regions of flow where the product of the instantaneous fluctuations of two velocity components is higher than a threshold based on the long-time turbulence statistics, in the spirit of the three-dimensional quadrant analysis proposed by Lozano-Duran et al. (J. Fluid Mech., vol. 694, 2012, pp. 100-130). We consider both the direct contribution of the structures to the mean in-plane velocity components and their geometrical properties. The instantaneous phenomena taking place in the turbulent duct are compared with turbulent channel flow at Reynolds numbers of $Re_tau=180$ and $360$, based on friction velocity at the center-plane and channel half height. In the core region of the duct, the fractional contribution of intense events to the wall-normal component of the mean velocity is in very good agreement with that in the channel, despite the presence of the secondary flow in the former. Additionally, the shapes of the three-dimensional objects do not differ significantly in both flows. On the other hand, in the corner region of the duct, the proximity of the walls affects both the geometrical properties of the coherent structures and the contribution to the mean component of the vertical velocity, which is less relevant than that of the complementary portion of the flow not included in such objects. Our results show however that strong Reynolds shear-stress events, despite the differences observed between channel and duct, do not contribute directly to the secondary motion, and thus other phenomena need to be considered instead.