We observe the coherence of an interacting two-component Bose-Einstein condensate (BEC) surviving for seconds in a trapped Ramsey interferometer. Mean-field driven collective oscillations of two components lead to periodic dephasing and rephasing of condensate wave functions with a slow decay of the interference fringe visibility. We apply spin echo synchronous with the self-rephasing of the condensate to reduce the influence of state-dependent atom losses, significantly enhancing the visibility up to 0.75 at the evolution time of 1.5s. Mean-field theory consistently predicts higher visibility than experimentally observed values. We quantify the effects of classical and quantum noise and infer a coherence time of 2.8 s for a trapped condensate of 5.5e4 interacting atoms.