The cosmic star formation rate is observed to drop sharply after redshift z=2. We use a large, cosmological, smoothed particle hydrodynamics simulation to investigate how this decline is related to the evolution of gas accretion and to outflows driven by active galactic nuclei (AGN). We find that the drop in the star formation rate follows a corresponding decline in the global cold-mode accretion rate density onto haloes, but with a delay of order the gas consumption time scale in the interstellar medium. Here we define cold-mode (hot-mode) accretion as gas that is accreted and whose temperature has never exceeded (did exceed) 10^5.5 K. In contrast to cold-mode accretion, which peaks at z~3, the hot mode continues to increase to z~1 and remains roughly constant thereafter. By the present time, the hot mode strongly dominates the global accretion rate onto haloes. Star formation does not track hot-mode halo accretion because most of the hot halo gas never accretes onto galaxies. AGN feedback plays a crucial role by preferentially preventing gas that entered haloes in the hot mode from accreting onto their central galaxies. Consequently, in the absence of AGN feedback, gas accreted in the hot mode would become the dominant source of fuel for star formation and the drop off in the cosmic star formation rate would be much less steep.