We report results of Raman scattering experiments on twin-free BaFe2As2 with the main focus placed on understanding the influence of electronic and spin degrees of freedom on the lattice dynamics. In particular, we scrutinize the Eg modes and the As A1g mode. Each of the two Eg phonons in the tetragonal phase is observed to split into a B2g and a B3g mode upon entering the orthorhombic stripe-magnetic phase. The splitting amounts to approximately 10 cm −1 and less than 5 cm −1 for the low-and the high-energy Eg mode, respectively. The detailed study of the fully symmetric As mode using parallel incident and outgoing photon polarizations along either the antiferromagnetic or the ferromagnetic Fe-Fe direction reveals an anisotropic variation of the spectral weight with the energy of the exciting laser indicating a polarization-dependent resonance effect. Along with the experiments we present results from density functional theory calculations of the phonon eigenvectors, the dielectric function, and the Raman tensor elements. The comparison of theory and experiment indicates that (i) orbital-selective electronic correlations are crucial to understand the lattice dynamics and (ii) all phonon anomalies originate predominantly from the magnetic ordering and the corresponding reconstruction of the electronic bands at all energies.