In the standard quasar model, the accretion disc obscuration is due to the canonical dusty torus. Here, we argue that a substantial part of the quasar obscuration can come from the interstellar medium (ISM) when the quasars are embedded in compact starbursts. We use an obscuration-unbiased sample of 578 infrared (IR) quasars at z ≈ 1–3 and archival Atacama Large Millimetre/submillimetre Array submillimetre host galaxy sizes to investigate the ISM contribution to the quasar obscuration. We calculate star formation rates (SFR) and ISM column densities for the IR quasars and a control sample of submillimetre galaxies (SMGs) not hosting quasar activity and show that: (1) the quasar obscured fraction is constant up to |$\rm SFR\approx 300 \: {\rm M}_{\odot } \: yr^{-1}$| , and then increases towards higher SFR, suggesting that the ISM obscuration plays a significant role in starburst host galaxies, and (2) at |$\rm SFR\gtrsim 300 \: {\rm M}_{\odot } \: yr^{-1}$| , the SMGs and IR quasars have similarly compact submillimetre sizes (|$R_{\rm e}\approx 0.5{\!-\!}3\,\mathrm{ kpc}$|) and consequently, the ISM can heavily obscure the quasar, even reaching Compton-thick (|$N_{\rm H}\gt 10^{24} \rm \: cm^{-2}$|) levels in extreme cases. Based on our results, we infer that |${\approx} 10{\!-\!}30~{{ \rm per\ cent}}$| of the IR quasars with |$\rm SFR\gtrsim 300 \: {\rm M}_{\odot } \: yr^{-1}$| are obscured solely by the ISM. [ABSTRACT FROM AUTHOR]