We study amenability of definable groups and topological groups, and prove various results, briefly described below. Among our main technical tools, of interest in its own right, is an elaboration on and strengthening of the Massicot-Wagner version (Massicot and Wagner in J Ec Polytech Math 2:55–63, 2015) of the stabilizer theorem (Hrushovski in J Am Math Soc 25:189–243, 2012), and also some results about measures and measure-like functions (which we call means and pre-means). As an application we show that if G is an amenable topological group, then the Bohr compactification of G coincides with a certain “weak Bohr compactification” introduced in Krupiński and Pillay (Adv Math 345:1253–1299, 2019). In other words, the conclusion says that certain connected components of G coincide: $$G^{00}_{{{\,\mathrm{{top}}\,}}} = G^{000}_{{{\,\mathrm{{top}}\,}}}$$
G
top
00
=
G
top
000
. We also prove wide generalizations of this result, implying in particular its extension to a “definable-topological” context, confirming the main conjectures from Krupiński and Pillay (2019). We also introduce $$\bigvee $$
⋁
-definable group topologies on a given $$\emptyset $$
∅
-definable group G (including group topologies induced by type-definable subgroups as well as uniformly definable group topologies), and prove that the existence of a mean on the lattice of closed, type-definable subsets of G implies (under some assumption) that $${{\,\mathrm{{cl}}\,}}(G^{00}_M) = {{\,\mathrm{{cl}}\,}}(G^{000}_M)$$
cl
(
G
M
00
)
=
cl
(
G
M
000
)
for any model M. Secondly, we study the relationship between (separate) definability of an action of a definable group on a compact space [in the sense of Gismatullin et al. (Ann Pure Appl Log 165:552–562, 2014)], weakly almost periodic (wap) actions of G [in the sense of Ellis and Nerurkar (Trans Am Math Soc 313:103–119, 1989)], and stability. We conclude that any group G definable in a sufficiently saturated structure is “weakly definably amenable” in the sense of Krupiński and Pillay (2019), namely any definable action of G on a compact space supports a G-invariant probability measure. This gives negative solutions to some questions and conjectures raised in Krupiński (J Symb Log 82:1080–1105, 2017) and Krupiński and Pillay (2019). Stability in continuous logic will play a role in some proofs in this part of the paper. Thirdly, we give an example of a $$\emptyset $$
∅
-definable approximate subgroup X in a saturated extension of the group $${{\mathbb {F}}}_2 \times {{\mathbb {Z}}}$$
F
2
×
Z
in a suitable language (where $${{\mathbb {F}}}_2$$
F
2
is the free group in 2-generators) for which the $$\bigvee $$
⋁
-definable group $$H:=\langle X \rangle $$
H
:
=
⟨
X
⟩
contains no type-definable subgroup of bounded index. This refutes a conjecture by Wagner and shows that the Massicot-Wagner approach to prove that a locally compact (and in consequence also Lie) “model” exists for each approximate subgroup does not work in general (they proved in (Massicot and Wagner 2015) that it works for definably amenable approximate subgroups).