The ALICE experiment at the LHC has studied J/psi production at mid-rapidity in pp collisions at root s = 7 TeV through its electron pair decay on a data sample corresponding to an integrated luminosity L-int = 5.6 nb(-1). The fraction of J/psi from the decay of long-lived beauty hadrons was determined for J/psi candidates with transverse momentum p(t) > 1,3 GeV/c and rapidity vertical bar y vertical bar < 0.9. The cross section for prompt J/psi mesons, i.e. directly produced J/psi and prompt decays of heavier charmonium states such as the psi(2S) and chi(c) resonances, is sigma(prompt J/psi) (p(t) > 1.3 GeV/c, vertical bar y vertical bar < 0.9) = 8.3 +/- 0.8(stat.) +/- 1.1 (syst.)(-1.4)(+1.5) (syst. pol.) mu b. The cross section for the production of b-hadrons decaying to J/psi with p(t) > 1.3 GeV/c and vertical bar y vertical bar < 0.9 is a sigma(J/psi <- hB) (p(t) > 1.3 GeV/c, vertical bar y vertical bar < 0.9) = 1.46 +/- 0.38 (stat.)(-0.32)(+0.26) (syst.) mu b. The results are compared to QCD model predictions. The shape of the p(t) and y distributions of b-quarks predicted by perturbative QCD model calculations are used to extrapolate the measured cross section to derive the b (b) over bar pair total cross section and d sigma/dy at mid-rapidity.