We introduce a natural extension of the colouring numbers of knots, called colouring polynomials, and study their relationship to Yang-Baxter invariants and quandle 2-cocycle invariants.For a knot K in the 3-sphere, let π K be the fundamental group of the knot complement ޓ 3 K , and let m K , l K ∈ π K be a meridian-longitude pair. Given a finite group G and an element x ∈ G we consider the set of representations ρ : π K → G with ρ(m K ) = x and define the colouring polynomial as ρ ρ(l K ). The resulting invariant maps knots to the group ring ޚG. It is multiplicative with respect to connected sum and equivariant with respect to symmetry operations of knots. Examples are given to show that colouring polynomials distinguish knots for which other invariants fail, in particular they can distinguish knots from their mutants, obverses, inverses, or reverses.We prove that every quandle 2-cocycle state-sum invariant of knots is a specialization of some knot colouring polynomial. This provides a complete topological interpretation of these invariants in terms of the knot group and its peripheral system. Furthermore, we show that the colouring polynomial can be presented as a Yang-Baxter invariant, i.e. as the trace of some linear braid group representation. This entails that Yang-Baxter invariants can detect noninversible and nonreversible knots.