The behavior of Re in magmas is of great significance to understanding the distribution of Re in Earth's different reservoirs. In order to better constrain the behavior of Re in magmas of different tectonic settings, the partition coefficients (D) of Re and Mo between sulfide liquid (SL), monosulfide solid solution (MSS), and basaltic to dacitic melts (SM) were determined using a piston-cylinder apparatus. The experiments were conducted at 1050-1200°C, 0.7-1.5 GPa, and oxygen fugacity (fO2) of ∼FMQ−1.8 to FMQ+1.5. The D values range from 0.11 to 76 for DMoSL/SM, 0.32 to 219 for DMoMSS/SM, 45 to 76000 for DReSL/SM, and 280 to 160000 for DReMSS/SM. All the D values increase with decreasing fO2 and the FeO content in silicate melt. We also find that DReSL/SM and DReMSS/SM are strongly correlated with DMoSL/SM and DMoMSS/SM regardless of the temperature, pressure, silicate melt composition, and fO2. This correlation, which can be explained by the similar dissolution behaviors of Re and Mo in silicate melt, provides an approach to use DMoSL/SM or DMoMSS/SM to predict DReSL/SM or DReMSS/SM in magmas. The newly obtained DReSL/SM, DReMSS/SM, DMoSL/SM, and DMoMSS/SM, in conjunction with DCuSL/SM, were applied to constrain the behavior of Re during magmatic genesis and differentiation. The results show that the observed Re contents in primitive MORBs can be explained only if the Re abundance in the depleted mantle is between 0.12 and 0.28 ppb. To satisfactorily explain both the Cu and Re contents in primitive arc basalts, (1) the fO2 of the subarc mantle during melting must be between FMQ and FMQ+1, and (2) the subducting slab must contribute both Re and S to the subarc mantle, although the extent of slab contribution differs between arcs. During arc magmatic differentiation, a significant fraction of Re is sequestered by sulfide, which results in a heterogeneous distribution of Re in the continental crust and the formation of Re-rich cumulates in the deep crust. The heterogeneous distribution of Re in the continental crust may lead to overestimations or underestimations of the Re abundance in the continental crust. The delamination of such Re-rich cumulates can form Re-rich and radiogenic Os-rich reservoirs in the depleted mantle, which partially explains the “missing Re” problem. Our study illustrates that sulfides play a key role in controlling the behavior of Re in magmas of mid-ocean ridge and arc settings and consequently, the distribution of Re in Earth's crust and mantle.