For a homogeneous space with connected or abelian stabilizer of a connected linear algebraic group defined over a number field, a cohomological obstruction to the Hasse principle is defined in terms of Galois hypercohomology with coefficients in a complex of two abelian algebraic groups. This obstruction is proved to be the only obstruction to the Hasse principle. It is proved that up to sign this cohomological obstruction coincides with the Brauer-Manin obstruction.