A search is made for a vectorlike T quark decaying into a Higgs boson and a top quark in 13 TeV proton-proton collisions using the ATLAS detector at the Large Hadron Collider with a data sample corresponding to an integrated luminosity of 139 fb-1. The Higgs-boson and top-quark candidates are identified in the all-hadronic decay mode, where H→bb¯ and t→bW→bqq¯′ are reconstructed as large-radius jets. The candidate Higgs boson, top quark, and associated B hadrons are identified using tagging algorithms. No significant excess is observed above the background, so limits are set on the production cross section of a singlet T quark at 95% confidence level, depending on the mass mT and coupling κT of the vectorlike T quark to Standard Model particles. In the considered mass range between 1.0 and 2.3 TeV, the upper limit on the allowed coupling values increases with mT from a minimum value of 0.35 for 1.07<mT<1.4 TeV to 1.6 for mT=2.3 TeV.