According to the one of the resources I attached, the earth itself was formed from the solar nebula "about 5 billion years ago." As the earth began to cool somewhat, the atmosphere was the first of these two resources to form and take place. It is also believed the oceans would have evaporated away, were not a form of atmosphere in place to prevent the water from escaping into space. The first atmosphere formed as a result of "vapor and gasses that were expelled during the degassing of the earth's interior." This first, early version of earth's atmosphere had "hydrogen, methane, water vapor, and carbon oxides."
The water on the earth, which represents that part of the earth called the hydrosphere, came about as a result of continued earth cooling. This continued cooling of the earth's surface caused the water vapor in the already present atmosphere to condense. The earth's oceans were formed from this condensation around four billion years ago. it was in these early oceans an early life form, blue-green algae, evolved to the point of using the sun's energy to make food through photosynthesis. This process is what is believed to have initiated the movement to oxygen being present in the present atmosphere.
The atmosphere, or air, was first, followed by the water.