We prove several theorems relating amenability of groups in various categories (discrete, definable, topological, automorphism group) to model-theoretic invariants (quotients by connected components, Lascar Galois group, G-compactness, ...). For example, if $M$ is a countable, $omega$-categorical structure and $Aut(M)$ is amenable, as a topological group, then the Lascar Galois group $Gal_{L}(T)$ of the theory $T$ of $M$ is compact, Hausdorff (also over any finite set of parameters), that is $T$ is G-compact. An essentially special case is that if $Aut(M)$ is extremely amenable, then $Gal_{L}(T)$ is trivial, so, by a theorem of Lascar, the theory $T$ can be recovered from its category $Mod(T)$ of models. On the side of definable groups, we prove for example that if $G$ is definable in a model $M$, and $G$ is definably amenable, then the connected components ${G^{*}}^{00}_{M}$ and ${G^{*}}^{000}_{M}$ coincide, answering positively a question from an earlier paper of the authors. We also take the opportunity to further develop the model-theoretic approach to topological dynamics, obtaining for example some new invariants for topological groups, as well as allowing a uniform approach to the theorems above and the various categories.