Anxiety is characterized by altered brain networks. Directional information flows among dynamic brain networks concerning neuropathogenesis of anxiety have not yet been investigated. The role of directional influences between networks in gene–environment effects on anxiety remains to be further elucidated. In a large community sample, this resting‐state functional MRI study estimated dynamic effective connectivity among large‐scale brain networks based on a sliding‐window approach and Granger causality analysis, providing dynamic and directional information for signal transmission in networks. We first explored altered effective connectivity among networks related to anxiety in distinct connectivity states. Due to the potential gene–environment effects on brain and anxiety, we further performed mediation and moderated mediation analyses to investigate the role of altered effective connectivity networks in relationships between polygenic risk scores, childhood trauma, and anxiety. State and trait anxiety scores showed correlations with altered effective connectivity among extensive networks in distinct connectivity states (p < .05, uncorrected). Only in a more frequent and strongly connected state, there were significant correlations between altered effective connectivity networks and trait anxiety (PFDR <0.05). Furthermore, mediation and moderated mediation analyses showed that the effective connectivity networks played a mediating role in the effects of childhood trauma and polygenic risk on trait anxiety. State‐dependent effective connectivity changes among brain networks were significantly related to trait anxiety, and mediated gene–environment effects on trait anxiety. Our work sheds novel light on the neurobiological mechanisms underlying anxiety, and provides new insights into early objective diagnosis and intervention evaluation.