An inversion layer makes Bay Area mountains warmer, not colder, at high elevations

By CBS Bay Area
Normally, when you climb up a mountain, it gets colder as you get higher. But that’s definitely not always the case in the Bay Area, especially during the summer.
Let’s zoom in on Mt. Tam. Here’s what a ‘normal’ weather setup would look like going up the mountain: 65 degrees near the base, 60 around 1000′, and 55 at the peak, getting cooler as you go up. But just a couple of days ago, it was 56 on Panoramic Highway just southwest of Mill Valley at around 800′ elevation, 60 on Hogback Road, which is around 1,000′, and spiking up to 87 on top of middle peak at around 2500, nearly 30 degrees warmer on the peak! Those were the highs across the area, and it’s been very similar for most of August.
So, why was it so much hotter on top of Mt. Tam compared to the elevations below? That’s thanks to something known as the inversion layer.
High altitudes are cooler mainly because of air pressure. There’s literally less air above you on a mountain compared to sea level, meaning less weight from the air above and lower pressure. With lower pressure, the air is able to spread out more, and as molecules expand, they use up energy, which lowers the temperature. Air is warmest at the surface and gradually becomes cooler the higher you go.
But an inversion layer, which has been setting up a lot this August in the Bay Area, brings the complete opposite weather. The Pacific Ocean is chilly, with water temperatures in the 50s and 60s along the central California coast, which is typically cooler than the daytime highs on land. The sea breeze picks up in the afternoon, which ushers in air cooled off by the ocean and fog across the Bay. The surface is now cooler than the air directly above it, and cold air sinks. But even when the air tries to rise as the sun comes out, it gets stopped by the blob of warm air above it and creates the inversion layer.
Normally, our inversion layer is around 1000′-2000′, keeping the fog in place as a shallow bubble of marine-kissed air at the surface. It would be so much hotter in the summer without the marine and inversion layers. But above the inversion layer it’s sunny, dry, and hot, which is one reason that fire danger is elevated on mountain peaks right now; with the inversion layer in place, it’s warmer and drier on higher elevations where a lot of dry fuels are already located.
So, on days you see the top of Mt. Tam is hotter than the elevations below, you know it’s because of an inversion layer! And the inversion layer is also what brings bad air quality in the winter, because it traps all the pollution at the surface along with the cooler air.