This paper has three main goals.First, we study fixed subgroups of automorphisms of right-angled Artin and Coxeter groups. If ' is an untwisted automorphism of a RAAG, or an arbitrary automorphism of a RACG, we prove that Fix ' is finitely generated and undistorted. Up to replacing ' with a power, we show that Fix ' is quasiconvex with respect to the standard word metric. This implies that Fix ' is a virtual retract and a special group in the sense of Haglund and Wise. By contrast, there exist "twisted" automorphisms of RAAGs for which Fix ' is undistorted but not of type F (hence not special), of type F but distorted, or even infinitely generated.Secondly, we introduce the notion of "coarse-median preserving" automorphism of a coarse median group, which plays a key role in the above results. We show that automorphisms of RAAGs are coarse-median preserving if and only if they are untwisted. On the other hand, all automorphisms of Gromov-hyperbolic groups and right-angled Coxeter groups are coarse-median preserving. These facts also yield new or more elementary proofs of Nielsen realisation for RAAGs and RACGs.Finally, we show that, for every special group G (in the sense of Haglund and Wise), every infinite-order, coarse-median preserving outer automorphism of G can be realised as a homothety of a finite-rank median space X equipped with a "moderate" isometric G-action. This generalises the classical result, due to Paulin, that every infinite-order outer automorphism of a hyperbolic group H projectively stabilises a small H -tree.