A search for direct pair production of scalar partners of the top quark (top squarks or scalar third-generation up-type leptoquarks) in the all-hadronic t (t) over bar plus missing transverse momentum final state is presented. The analysis of 139 fb(-1) of root s = 13 TeV proton-proton collision data collected using the ATLAS detector at the LHC yields no significant excess over the Standard Model background expectation. To interpret the results, a supersymmetric model is used where the top squark decays via (t) over tilde -> t(*) (chi) over tilde (0)(1), with t(*) denoting an on-shell (off-shell) top quark and (chi) over tilde (0)(1) the lightest neutralino. Three specific event selections are optimised for the following scenarios. In the scenario where m((t) over tilde) > m(t) + m((chi) over tilde 10), top squark masses are excluded in the range 400-1250 GeV for (chi) over tilde (0)(1) masses below 200 GeV at 95% confidence level. In the situation where m((t) over tilde) similar to m(t) + m((chi) over tilde 10), top squarkmasses in the range 300-630 GeV are excluded, while in the case where m((t) over tilde) < m(W) + m(b) + m(<(chi)over tilde>10) (with m((t) over tilde) - m((chi) over tilde 10) >= 5 GeV), considered for the first time in an ATLAS all-hadronic search, top squark masses in the range 300-660 GeV are excluded. Limits are also set for scalar third-generation up-type leptoquarks, excluding leptoquarks with masses below 1240 GeV when considering only leptoquark decays into a top quark and a neutrino.