The persistence diagram of a real-valued function on a topological space is a multiset of points in the extended plane. We prove that under mild assumptions on the function, the persistence diagram is stable: small changes in the function imply only small changes in the diagram. We apply this result to estimating the homology of sets in a metric space and to comparing and classifying geometric shapes. Categories and Subject Descriptors F.2.2 [Analysis of Algorithms and Problem Complexity]: Nonnumerical Algorithms and Problems—Geometrical problems and computations, Computations on discrete structures; G.2.1 [Discrete Mathematics]: Combinatorics—Counting problems General Terms Algorithms, Theory Keywords Combinatorial topology, continuous functions, homology groups, persistence, stability