We analyze the Sun as a source for the indirect detection of dark matter through a search for gamma rays from the solar disk. Capture of dark matter by elastic interactions with the solar nuclei followed by annihilation to long-lived mediators can produce a detectable gamma-ray flux. We search 3 years of data from the High Altitude Water Cherenkov (HAWC) observatory and find no statistically significant detection of TeV gamma-ray emission from the Sun. Using this, we constrain the spin-dependent elastic scattering cross section of dark matter with protons for dark matter masses above 1 TeV, assuming a sufficiently long-lived mediator. The results complement constraints obtained from Fermi-LAT observations of the Sun and together cover WIMP masses between 4 and 10 6 GeV. In the optimal scenario, the cross-section constraints for mediator decays to gamma rays can be as strong as ∼10 −45 cm 2 , which is more than 4 orders of magnitude stronger than current direct-detection experiments for a 1 TeV dark matter mass. The cross-section constraints at higher masses are even better, nearly 7 orders of magnitude better than the current direct-detection constraints for a 100 TeV dark matter mass. This demonstration of sensitivity encourages detailed development of theoretical models in light of these powerful new constraints.