A direct search for Higgs bosons produced via vector-boson fusion and subsequently decaying into invisible particles is reported. The analysis uses 139 fb(-1) of pp collision data at a centre-of-mass energy of root s =13 TeV recorded by the ATLAS detector at the LHC. The observed numbers of events are found to be in agreement with the background expectation from Standard Model processes. For a scalar Higgs boson with a mass of 125 GeV and a Standard Model production cross section, an observed upper limit of 0.145 is placed on the branching fraction of its decay into invisible particles at 95% confidence level, with an expected limit of 0.103. These results are interpreted in the context of models where the Higgs boson acts as a portal to dark matter, and limits are set on the scattering cross section of weakly interacting massive particles and nucleons. Invisible decays of additional scalar bosons with masses from 50 GeV to 2 TeV are also studied, and the derived upper limits on the cross section times branching fraction decrease with increasing mass from 1.0 pb for a scalar boson mass of 50 GeV to 0.1 pb at a mass of 2 TeV.