  For any dg algebra $A$, not necessarily commutative, and a subset $S$ in
$H(A)$, the homology of $A$, we construct its derived localisation $L_S(A)$
together with a map $A\to L_S(A)$, well-defined in the homotopy category of dg
algebras, which possesses a universal property, similar to that of the ordinary
localisation, but formulated in homotopy invariant terms. Even if $A$ is an
ordinary ring, $L_S(A)$ may have non-trivial homology. Unlike the commutative
case, the localisation functor does not commute, in general, with homology but
instead there is a spectral sequence relating $H(L_S(A))$ and $L_S(H(A))$; this
spectral sequence collapses when, e.g. $S$ is an Ore set or when $A$ is a free
ring.
  We prove that $L_S(A)$ could also be regarded as a Bousfield localisation of
$A$ viewed as a left or right dg module over itself. Combined with the results
of Dwyer-Kan on simplicial localisation, this leads to a simple and conceptual
proof of the topological group completion theorem. Further applications include
algebraic $K$-theory, cyclic and Hochschild homology, strictification of
homotopy unital algebras, idempotent ideals, the stable homology of various
mapping class groups and Kontsevich's graph homology.
