It is a great challenge to achieve moderate improvements in flame retardancy and toughness of epoxy/anhydride thermosets with uncompromised processability, heat resistance, and mechanical strength. Herein, a phosphorus- and fluorine-containing hyperbranched anhydride-end-capped imide oligomer (HAPI) was synthesized and used as the cohardener of methylhexahydrophthalic anhydride (MHHPA) to prepare multifunctional epoxy/anhydride systems (EP/HAPI). Thanks to the hyperbranched structure and spherical nature of HAPI, the EP/HAPI-3 system with 30.4 wt % HAPI had good processability with a viscosity below 1.0 Pa s at 110 degrees C. After curing, the EP/HAPI-3 thermoset possessed good flame retardancy, showing a limiting oxygen index value of 30.3% at 0.68 wt % phosphorus. Meanwhile, the EP/HAPI-3 thermoset had attractive toughness, as indicated by the 123% increase in impact strength, attributed to the expanded free volume originating from the hyperbranched structure. In addition, EP/HAPI-3 thermoset exhibited a high glass transition temperature (T-g) of 156.2 degrees C, a low dielectric constant of 2.98 at 100 MHz, and a 36.7 and 39.7% increase in Young's modulus (4.21 +/- 0.12 GPa vs 3.08 +/- 0.10 GPa) and tensile strength (89.3 +/- 1.9 MPa vs 63.9 +/- 1.7 MPa), respectively, compared to the original epoxy thermoset. This work provides a facile and practical approach to prepare epoxy/anhydride thermosets with simultaneously improved overall properties by the bespoke multifunctional hyperbranched imide oligomers, and the resulting epoxy thermosets have great potential for application as advanced electrical materials.