Of course the forgiveness comes from God. But in he case of the Sacraments such as "absolution" (forgiving) the Priest receives the power through the Holy Spirit, and the Holy Spirit provides this special gift through the process of "succession." That means there is an unbroken line of Bishops laying hands on priests which can me traced directly back to the Last Supper. It is directly because of the commission at the Last Supper on the Apostles, who laid hands on Bishops who laid hands on priests who were appointed bishops who laid hands on priests etc..., that the priests of today who are in an unbroken lineage to that day have this unique role.
In the Old Testament we see prophets passing on power to their successors by the laying on of hands and anointing. For example:
Joshua son of Nun was full of the spirit of wisdom, because Moses had laid his hands on him (Deut 31:1-8)
You [Elijah] shall anoint Elisha son of Shaphat of Abel-meholah as prophet in your place (1 Kg 19:16)
...Samuel took a horn of oil, and anointed him in the presence of his brothers and then spirit of the Lord came mightily upon David from that day forward. (1 Sam 16:13)
So the LORD said to Moses, "Gather for me seventy of the elders of Israel ... bring them to the tent of meeting, and have them take their place there with you. I will come down and talk with you there; and I will take some of the spirit that is on you and put it on them; and they shall bear the burden of the people along with you so that you will not bear it all by yourself....and he gathered seventy elders of the people, and placed them all around the tent. Then the LORD came down in the cloud and spoke to him, and took some of the spirit that was on him and put it on the seventy elders; and when the spirit rested upon them, they prophesied." (Num 11:16 -25)
Catholics believe these were a foreshadowing of Christ's ministry. In the New Testament:
After this the Lord appointed seventy others and sent them on ahead of him in pairs to every town and place where he himself intended to go. (Lk 10:1)
Jesus said..."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." (John 20:21-23)
Perhaps an important thing to note is that Thomas was not present at this time - but he did receive the gift. This suggests that perhaps Peter (who was given the keys to the kingdom) gave it to him. Jesus said to Peter "whatever you bind on earth will be bound in heaven and whatever you loose on earth will be loosed in heaven" (Mat 16:19)
These apostles prayed over the next generation of apostles. Some of them became Bishops. The Bishops in turn prayed over the newly ordained priests. Every priest from the beginning of the Church right back to Peter was prayed over in the same way. And hence Catholics feel that from generation to generation this Grace has been passed on.