The direct basis for these beliefs are found in three passages, taught by Jesus Himself:
Matthew 16:19 (RSV) I will give you the keys of the kingdom of heaven, and whatever you bind on earth shall be bound in heaven, and whatever you loose on earth shall be loosed in heaven.
Matthew 18:18 Truly, I say to you, whatever you bind on earth shall be bound in heaven, and whatever you loose on earth shall be loosed in heaven.
John 20:21-23 Jesus said to them again, “Peace be with you. As the Father has sent me, even so I send you.” And when he had said this, he breathed on them, and said to them, “Receive the Holy Spirit. If you forgive the sins of any, they are forgiven; if you retain the sins of any, they are retained.”
“Binding” and “loosing” were rabbinical terms that had to do with authority to punish or pardon. We see the Apostle Paul literally exercising these prerogatives with the Corinthians. He “binds” in 1 Corinthians 5:1-5 (what Catholics would call “imposing a penance”) and “looses” in 2 Corinthians 2:6-11.
Paul forgives another man for a transgression that wasn’t personally committed against him, and instructs the Corinthians to do the same (the sin wasn’t committed against all of them, either). So both he and the Corinthians as a whole were acting as “God’s representatives” in the matter of forgiving sins:
1 Corinthians 5:1-5 It is actually reported that there is immorality among you, and of a kind that is not found even among pagans; for a man is living with his father’s wife. And you are arrogant! Ought you not rather to mourn? Let him who has done this be removed from among you. For though absent in body I am present in spirit, and as if present, I have already pronounced judgment in the name of the Lord Jesus on the man who has done such a thing. When you are assembled, and my spirit is present, with the power of our Lord Jesus, you are to deliver this man to Satan for the destruction of the flesh, that his spirit may be saved in the day of the Lord Jesus.
2 Corinthians 2:6-11 For such a one this punishment by the majority is enough; so you should rather turn to forgive and comfort him, or he may be overwhelmed by excessive sorrow. So I beg you to reaffirm your love for him. For this is why I wrote, that I might test you and know whether you are obedient in everything. Any one whom you forgive, I also forgive. What I have forgiven, if I have forgiven anything, has been for your sake in the presence of Christ, to keep Satan from gaining the advantage over us; for we are not ignorant of his designs.