Hydrocarbons are ubiquitous in the ocean, where alkanes such as pentadecane and heptadecane can be found even in waters minimally polluted with crude oil. Populations of hydrocarbon-degrading bacteria, which are responsible for the turnover of these compounds, are also found throughout marine systems, including in unpolluted waters. These observations suggest the existence of an unknown and widespread source of hydrocarbons in the oceans. Here, we report that strains of the two most abundant marine cyanobacteria, Prochlorococcus and Synechococcus, produce and accumulate hydrocarbons, predominantly C15 and C17 alkanes, between 0.022 and 0.368% of dry cell weight. Based on global population sizes and turnover rates, we estimate that these species have the capacity to produce 2–540 pg alkanes per mL per day, which translates into a global ocean yield of ∼308–771 million tons of hydrocarbons annually. We also demonstrate that both obligate and facultative marine hydrocarbon-degrading bacteria can consume cyanobacterial alkanes, which likely prevents these hydrocarbons from accumulating in the environment. Our findings implicate cyanobacteria and hydrocarbon degraders as key players in a notable internal hydrocarbon cycle within the upper ocean, where alkanes are continually produced and subsequently consumed within days. Furthermore we show that cyanobacterial alkane production is likely sufficient to sustain populations of hydrocarbon-degrading bacteria, whose abundances can rapidly expand upon localized release of crude oil from natural seepage and human activities.