We present an enhanced version of the multiwavelength spectral modeling code MAGPHYS that allows the estimation of galaxy photometric redshift and physical properties (e.g., stellar mass, star formation rate, dust attenuation) simultaneously, together with robust characterization of their uncertainties. The self-consistent modeling over ultraviolet to radio wavelengths in MAGPHYS+photo-z is unique compared to standard photometric redshift codes. The broader wavelength consideration is particularly useful for breaking certain degeneracies in color vs. redshift for dusty galaxies with limited ultraviolet and optical data (or upper limits). We demonstrate the success of the code in estimating redshifts and physical properties for over 4,000 infrared-detected galaxies at 0.4 < z < 6.0 in the COSMOS field with robust spectroscopic redshifts. We achieve high photo-z precision, high accuracy (i.e., minimal offset biases), and low catastrophic failure rates over all redshifts. Interestingly, we find that a weak 2175A absorption feature in the attenuation curve models is required to remove a subtle systematic photo-z offset that occurs for dusty galaxies when this feature is not included. As expected, the accuracy of derived physical properties in MAGPHYS+photo-z decreases strongly as redshift uncertainty increases. The all-in-one treatment of uncertainties afforded with this code is beneficial for accurately interpreting physical properties of galaxies in large photometric datasets.