We study a general problem of the translational/rotational/vibrational/electronic dynamics of a diatomic molecule exposed to an interaction with an arbitrary external electromagnetic field. The theory developed in this paper is relevant to a variety of specific applications, such as alignment or orientation of molecules by lasers, trapping of ultracold molecules in optical traps, molecular optics and interferometry, rovibrational spectroscopy of molecules in the presence of intense laser light, or generation of high order harmonics from molecules. Starting from the first quantum mechanical principles, we derive an appropriate molecular Hamiltonian suitable for description of the center of mass, rotational, vibrational, and electronic molecular motions driven by the field within the electric dipole approximation. Consequently, the concept of the Born-Oppenheimer separation between the electronic and the nuclear degrees of freedom in the presence of an electromagnetic field is introduced. Special cases of the dc/ac-field limits are then discussed separately. Finally, we consider a perturbative regime of a weak dc/ac field, and obtain simple analytic formulas for the associated Born-Oppenheimer translational/rotational/vibrational molecular Hamiltonian.