  We present new broad-band optical and near-infrared CCD imaging together with
deep optical intermediate-resolution spectroscopy of the Hickson Compact Group
31. We analyze the morphology and colors of the stellar populations of the
galaxies, as well as the kinematics, physical conditions and chemical
composition of the ionized gas in order to get a more complete view on the
origin and evolution of the system. We estimate the ages of the most recent
star formation bursts of the system, finding an excellent consistency among the
values obtained with different indicators and starburst models. We find that
member F hosts the youngest starburst of the group, showing a substantial
population of Wolf-Rayet stars. The chemical abundances are fairly similar in
all the members of the group despite their very different absolute magnitudes.
We argue that the use of traditional metallicity-luminosity relations based on
the absolute $B$-magnitude is not appropriate for dwarf starburst galaxies,
because their luminosity is dominated by the transient contribution of the
starburst to the blue luminosity. We think that members E and F of the group
are candidate tidal dwarf galaxies because of their high metallicity, their
kinematics, and the absence of underlying old stellar populations. Finally, we
propose that HCG~31 is suffering several almost simultaneous interaction
processes. The most relevant of these processes are: (a) the merging of members
A and C, that would have produced two optical tidal tails; and (b) a fly-by
encounter between G and the A+C complex, that would have produced an \ion{H}{1}
tidal tail from the stripping of the external gas of A+C, from which members F
and E have originated.
