  The rank of a hierarchically hyperbolic space is the maximal number of
unbounded factors in a standard product region. For hierarchically hyperbolic
groups, this coincides with the maximal dimension of a quasiflat. Examples for
which the rank coincides with familiar quantities include: the dimension of
maximal Dehn twist flats for mapping class groups, the maximal rank of a free
abelian subgroup for right-angled Coxeter and Artin groups, and, for the
Weil--Petersson metric, the rank is the integer part of half the complex
dimension of Teichm\"{u}ller space.
  We prove that any quasiflat of dimension equal to the rank lies within finite
distance of a union of standard orthants (under a mild condition satisfied by
all natural examples). This resolves outstanding conjectures when applied to
various examples. For mapping class group, we verify a conjecture of Farb; for
Teichm\"{u}ller space we answer a question of Brock; for CAT(0) cubical groups,
we handle special cases including right-angled Coxeter groups. An important
ingredient in the proof is that the hull of any finite set in an HHS is
quasi-isometric to a CAT(0) cube complex of dimension bounded by the rank.
  We deduce a number of applications. For instance, we show that any
quasi-isometry between HHSs induces a quasi-isometry between certain simpler
HHSs. This allows one, for example, to distinguish quasi-isometry classes of
right-angled Artin/Coxeter groups. Another application is to quasi-isometric
rigidity. Our tools in many cases allow one to reduce the problem of
quasi-isometric rigidity for a given hierarchically hyperbolic group to a
combinatorial problem. We give a new proof of quasi-isometric rigidity of
mapping class groups, which, given our general quasiflats theorem, uses simpler
combinatorial arguments than in previous proofs.
