In smart ports, accurate perception of the state of a berthing ship relative to the berth is critical for the safety and efficiency of ships and ports. A real-time tracking and berthing system with occlusion handling based on Light Detection and Ranging (LiDAR) is proposed. First, the data is pre-processed, including fast filtering and clustering, and then a real-time tracking framework is proposed to solve the occlusion problem. This framework adapts to different berthing scenarios through accurate determination of dynamic and static targets and efficient retracking of berthing ships. To verify the effectiveness of the method, an on-site monitoring experiment of the “Yukun” training ship in Dalian Port is conducted, and a simulated berthing scene under occlusion is constructed to test the algorithm. The practical results prove that our method shows feasibility and effectiveness in the application of ship dynamic target tracking and safe ship berthing.