Cloud detection by passive satellite sensors is very challenging in hazy weather over China because the reflective characteristics of haze and clouds are very similar. Consequently, hazy areas tend to be mistaken as cloudy or clear areas by current cloud mask algorithms. The Advanced Himawari Imager (AHI) aboard Himawari‐8 is a multispectral Earth observation sensor with high temporal and spatial resolutions. A cloud and haze detection algorithm for AHI measurements is urgently needed for monitoring atmospheric pollution and its transport over China. This study presents the new Himawari‐8 Cloud and Haze Mask (HCHM) algorithm that classifies image pixels from central and eastern China into one of three categories: clear, cloudy, or hazy. Based on the observations that haze occurs near the ground and accumulates in low‐elevation plains and basins while clouds form at high altitudes, the proposed HCHM algorithm incorporates altitude information to adjust the thresholds used in the selected threshold tests to separate haze and cloud pixels. We find that combining auxiliary digital elevation model data with traditional indicators, such as the R0.86/R0.64, R0.86/R1.6, and BT11‐BT3.9, improves the accuracy of cloud and haze discrimination. The HCHM algorithm is applied to Himawari‐8 observations from August 2015, November 2015, January 2016, and May 2016 and validated against the Cloud‐Aerosol Lidar and Infrared Pathfinder Satellite Observation vertical feature mask results. The validation shows that the average leakage rate, false alarm rate, and haze missing rate of the HCHM algorithm are 3.95%, 5.88%, and 4.17%, respectively.