When water, a good electrolyte, hits an iron object combines with carbon dioxide in the air to form a weak carbonic acid, an even better electrolyte.
As the acid is formed and the iron dissolved, some of the water will begin to break down into its component pieces -- hydrogen and oxygen.
The free oxygen and dissolved iron bond into iron oxide, in the process freeing electrons. The electrons liberated from the anode portion of the iron flow to the cathode.
Oxides, such as iron oxide or rust form when oxygen combines with metals.