We consider an action of a finite-dimensional Hopf algebra H on a noncommutative associative algebra A. Properties of the invariant subalgebra A(H) in A are studied. It is shown that if A is integral over its centre Z(A) then in each of three cases A will be integral over Z(A)(H) (the invariant subalgebra in Z(A)): 1) the coradical H-0 is cocommutative and char k = p > 0; 2) H is pointed, A has no nilpotent elements, Z(A) is an affine algebra, and char k = 0; 3) H is cocommutative. We also consider an action of a commutative Hopf algebra H on an arbitrary associative algebra, in particular, the canonical action of H on the tensor algebra T(H). A structure theorem on Hopf algebras is proved by application of the technique developed. Namely, every commutative finite-dimensional Hopf algebra H whose coradical H-0 is a sub-Hopf algebra or cocommutative, where char k = 0 or char k > dim H, is cosemisimple, that is, H = H-0. In particular, a commutative pointed Hopf algebra with char k = 0 or char k > dim H will be a group Hopf algebra. An example is also constructed showing that the restrictions on char k are essential.