I know that masquerading is to impersonate a false identity and replaying is the same wherein unauthorized person uses the credentials of the authorized one to have the privileges.Then what is the difference between the two terms?
These two terms do not have meanings at the same level. Masquerading (or impersonation; the two terms are equivalent) is any attack wherein the attackers acts (emits data packets or the like) as if he was some other user or entity in the system. Replay attacks are attacks where the attacker simply sends a data element (e.g. a data packet) which was previously sent by some other user, in the hope of reproducing the effect.
Thus, a "replay attack" is often a specific kind of impersonation; or you can consider replay attacks to be a tool used to implement an impersonation attack.
To try to answer your question more directly, an impersonation attack may be a replay or may be some other type of attack. (For example a man in the middle could impersonate the client by getting the legitimate information rather than simply replaying a previously recorded session.)
Similarly, a replay attack may or may not have anything to do with impersonation. While many replay attacks may be based on trying to impersonate a previous request, if proper IVs aren't being used on cryptographic communications, a replay attack could be used to inject incorrect information in to a stream as well without actually impersonating the user. It would instead simply be hijacking a legitimate action.
So in short, you are correct that the two terms are often related since replay may be used to impersonate in certain situations, but those aren't the only uses of the two concepts.