Consider Sym (n), endowed with the normalized Hamming metric d n . A finitely-generated group Γ is P-stable if every almost homomorphism ρ n k ∶ Γ → Sym (n k ) (i.e., for every g, h ∈ Γ, lim k→∞ d n k (ρ n k (gh) , ρ n k (g) ρ n k (h)) = 0) is close to an actual homomorphism ϕ n k ∶ Γ → Sym (n k ). Glebsky and Rivera observed that finite groups are P-stable, while Arzhantseva and Păunescu showed the same for abelian groups and raised many questions, especially about P-stability of amenable groups. We develop Pstability in general, and in particular for amenable groups. Our main tool is the theory of invariant random subgroups (IRS), which enables us to give a characterization of P-stability among amenable groups, and to deduce stability and instability of various families of amenable groups.In other words, every "almost homomorphism" from Γ to G n is close to an actual homomorphism. It is not difficult to show (see [3]) that the stability of Γ with respect to (G n , d n ) ∞ n=1 depends only on the group Γ, rather than the chosen presentation -so the notion is well-defined.1 The main results of this paper will be formulated and proved for general finitely-generated groups, but for the simplicity of the exposition in this introduction, we will assume that Γ is finitely-presented.