Ultrashort-period (USP) exoplanets have orbital periods shorter than 1 day. Precise masses and radii of USP exoplanets could provide constraints on their unknown formation and evolution processes. We report the detection and characterization of the USP planet GJ 367b using high-precision photometry and radial velocity observations. GJ 367b orbits a bright (V-band magnitude of 10.2), nearby, and red (M-type) dwarf star every 7.7 hours. GJ 367b has a radius of 0.718 ± 0.054 Earth-radii and a mass of 0.546 ± 0.078 Earth-masses, making it a sub-Earth planet. The corresponding bulk density is 8.106± 2.165 grams per cubic centimeter—close to that of iron. An interior structure model predicts that the planet has an iron core radius fraction of 86± 5%, similar to that of Mercury’s interior.