A marine layer is an air mass that develops over the surface of a large body of water such as the ocean or large lake in the presence of a temperature inversion. The inversion itself is usually initiated by the cooling effect of the water on the surface layer of an otherwise warm air mass.
As it cools, the surface air becomes denser than the warmer air above it, and thus becomes trapped below it. The layer may thicken through turbulence generated within the developing marine layer itself. It may also thicken if the warmer air above it is lifted by an approaching area of low pressure. The layer will also gradually increase its humidity by evaporation of the ocean or lake surface, as well as by the effect of cooling itself. Fog will form within a marine layer where the humidity is high enough and cooling sufficient to produce condensation. Stratus and stratocumulus will also form at the top of a marine layer in the presence of the same conditions there. A marine layer will disperse and break up in the presence of instability, such as may be caused by the passage of a frontal system or trough, or any upper air turbulence that impinges on it. A marine layer can also be driven away by sufficiently strong winds.
It is not unusual to hear media weather reporters discuss the marine layer as if it were synonymous with the fog or stratus it may contain, but this is erroneous. In fact, a marine layer can exist with virtually no cloudiness of any kind, although it usually does contain some. The marine layer is a medium within which clouds may form under the right conditions; it is not the layers of clouds themselves.
In the case of coastal California, the offshore marine layer is typically propelled inland by a pressure gradient which develops as a result of intense heating inland, blanketing coastal communities in cooler air which, if saturated, also contains fog. The fog lingers until the heat of the sun becomes strong enough to evaporate it, often lasting into the afternoon during the "June gloom" period. An approaching frontal system or trough can also drive the marine layer onshore.