The notion of almost Gorenstein ring given by Barucci and Fröberg [2] in the case where the local rings are analytically unramified is generalized, so that it works well also in the case where the rings are analytically ramified. As a sequel, the problem of when the endomorphism algebra m : m of m is a Gorenstein ring is solved in full generality, where m denotes the maximal ideal in a given Cohen-Macaulay local ring of dimension one. Characterizations of almost Gorenstein rings are given in connection with the principle of idealization. Examples are explored.