For an n-dimensional Leibniz/Lie algebra h over a field k we introduce a new invariant A(h), called the universal algebra of h, as a quotient of the polynomial algebra k[Xij|i,j=1,⋯,n] through an ideal generated by n3 polynomials. We prove that A(h) admits a unique bialgebra structure which makes it an initial object among all commutative bialgebras coacting on h. The new object A(h) is the key tool in answering two open problems in Lie algebra theory. First, we prove that the automorphism group AutLbz(h) of h is isomorphic to the group U(G(A(h)o)) of all invertible group-like elements of the finite dual A(h)o. Secondly, for an abelian group G, we show that there exists a bijection between the set of all G-gradings on h and the set of all bialgebra homomorphisms A(h)→k[G]. Based on this, all G-gradings on h are explicitly classified and parameterized. A(h) is also used to prove that there exists a universal commutative Hopf algebra associated to any finite dimensional Leibniz algebra h.