The Ice, Cloud and Land Elevation Satellite-2 (ICESat-2) mission employs a micro-pulse photon-counting LiDAR system for mapping and monitoring the biomass and carbon of terrestrial ecosystems over large areas. In preparation for ICESat-2 data processing and applications, this paper aimed to develop and validate an effective algorithm for better estimating ground elevation and vegetation height from photon-counting LiDAR data. Our new proposed algorithm consists of three key steps. Firstly, the noise photons were filtered out using a noise removal algorithm based on localized statistical analysis. Secondly, we classified the signal photons into canopy photons and ground photons by conducting a series of operations, including elevation frequency histogram building, empirical mode decomposition (EMD), and progressive densification. At the same time, we also identified the top of canopy (TOC) photons from canopy photons by percentile statistics method. Thereafter, the ground and TOC surfaces were generated from ground photons and TOC photons by cubic spline interpolation, respectively. Finally, the ground elevation and vegetation height were estimated by retrieved ground and TOC surfaces. The results indicate that the noise removal algorithm is effective in identifying background noise and preserving signal photons. The retrieved ground elevation is more accurate than the retrieved vegetation height, and the results of nighttime data are better than those of the corresponding daytime data. Specifically, the root-mean-square error (RMSE) values of ground elevation estimates range from 2.25 to 6.45 m for daytime data and 2.03 to 6.03 m for nighttime data. The RMSE values of vegetation height estimates range from 4.63 to 8.92 m for daytime data and 4.55 to 8.65 m for nighttime data. Our algorithm performs better than the previous algorithms in estimating ground elevation and vegetation height due to lower RMSE values. Additionally, the results also illuminate that the photon classification algorithm effectively reduces the negative effects of slope and vegetation coverage. Overall, our paper provides an effective solution for estimating ground elevation and vegetation height from micro-pulse photon-counting LiDAR data.