Future generation of landing craft will autonomously look at the surface during the terminal phase of powered descent and then, in real-time, choose and divert to a safe landing site in order to avoid hazards. Enabling technologies for such capability have been under development in recent years in the Autonomous Landing Hazard Avoidance Technology (ALHAT) project funded by NASA's Exploration Technology Development Program.ALHAT is a comprehensive system that spans the approach and landing events -from de-orbit coasting to touchdown. In this paper, we focus on ALHAT's perception task of detecting hazards in the sensed terrain and of selecting candidate safe sites for landing. This task, named Hazard Detection and Avoidance (HDA), occurs in the middle of the landing sequence. Our approach to HDA employs a probabilistic model in order to better manage the ubiquitous uncertainties associated with noisy sensor measurements and navigation. Also, we explicitly take into account the geometry of the lander and its interaction with the surface when assessing hazards. Experimental results on synthetic Lunar-like terrain show that our HDA algorithm can designate safe landing locations for a variety of terrain types and density and abundance of hazards. The complete ALHAT system is undergoing ground field-testing, and is scheduled for additional field tests on a one-hectare, lunar-like, hazard field recently constructed at NASA's Kennedy Space Center (KSC). Although the focus of ALHAT is on autonomous planetary landings, a number of terrestrial applications can also benefit from out HDA system.