
A marine layer is an air mass that develops over the surface of a large body of water, such as an ocean or large lake, in the presence of a temperature inversion. The inversion itself is usually initiated by the cooling effect caused when cold water on the surface of the ocean interacts with a comparatively warm air mass. The marine layer is the lowest layer of the atmosphere over the ocean.
A marine layer can come in a number of different forms depending on the atmospheric conditions. It may manifest itself as merely a cool, humid air mass without any cloud cover, or it may be accompanied by clouds. In many cases, marine layers can consist of dense fog. Often associated with marine layers are stratus clouds, which are lumpy, often uniform clouds that form at low elevations (less than 3000 feet). Ultimately, the marine layer is a medium within which clouds may form under the right conditions; it is not the layers of clouds themselves.
As air cools in a temperature inversion, the surface air becomes denser than the warmer air above it, and thus becomes trapped below it. The lower layer will also gradually increase its humidity by evaporation of the surface water, as well as by the effect of the cooling itself, since cooler air holds less moisture.
Clouds and potentially fog can form within a marine layer when the water-saturated air is cooled and reaches a humidity of 100%, where it will then condense and turn into water droplets. Stratus and stratocumulus can form at the top of a marine layer in the presence of these conditions. A marine layer can often be dispersed by sufficiently strong winds, which essentially blow it away. The sun can also evaporate the marine layer, as it warms air and land which decreases the relative humidity and causes marine layer clouds to evaporate.
Cold ocean currents and coastal upwellings also have an effect on the formation of the marine layer. The marine layer develops when the air near the ocean surface is cooled from below. In addition, coastal upwellings strengthen the cooling effect. These upwellings bring colder water from deeper in the ocean to the surface which helps to maintain a lower sea-surface temperature. The cooled air becomes more dense and remains near the surface. This contributes to the formation of the layer of cool air over the ocean and coastal areas. This is where the temperature inversion forms as the warm, dry air above the cool air layer separates the two masses. Since the atmosphere is stable, vertical mixing is reduced, so the cool marine layer stays trapped near the surface rather than mixing upward. The ocean continuously cools the air layer above it, allowing the marine layer to be maintained for extended periods of time.
Although the marine layer can stick around for several days, it often goes through a daily (diurnal) cycle. This cycle begins at night and into early morning. At this point in the cycle a temperature inversion is formed where cool, moist air is trapped near the surface beneath warmer air. The temperature inversion creates the cloud and fog layer that is transported by onshore wind to coastal plains and valleys. As the day progresses the sun begins to appear, and solar radiation penetrates through the clouds and warms the ground and water surfaces. The heating of the lower surfaces increases atmospheric mixing and raises the cloud base. This causes the marine layer to thin, evaporate, or move towards the coast. As the evening comes the sun begins to set and the ground and water surface begins to cool again with the combination of the lack of solar radiation and the presence of onshore wind. This starts the cycle over again as the surface begins to cool and traps the warmer air above it, creating the temperature inversion.

In the case of coastal California, the offshore marine layer is enabled by the cold relative sea surface temperatures of the Pacific Ocean. California receives this unusually cold water through a process called the California Current, where cool polar water is transported from the Gulf of Alaska to the California coast. This process creates anomalously cool water temperatures given the latitude of California, and causes a strong temperature inversion. Surface waters in coastal California are kept cold through a process called upwelling, which involves cooler, deeper waters rising to the top of a water column.
Occasionally the marine layer becomes particularly deep, and the clouds on land can persist all day. This can happen at any time of the year, inspiring colloquialisms such as "May Gray" or "June Gloom". An approaching frontal system or trough can also drive the marine layer onshore.
Though California is a notable example of the marine layer, these atmospheric phenomena exist in several other places around the world. Marine layers often form on the west coasts of continents, where upwelling usually occurs, and where there is a relatively warm air mass moving over a cool body of water. They can also form on the coasts of cool lakes, such as the Great Lakes in the United States.