The trinity dogma teaches that the Father (God), the son (Jesus) and the Holy Spirit (Ruh al-Qudus) together form God.
I know the argument from Christian apologetics, saying, the Prophet (p.b.u.h) didn't even know what Trinity is.
They may even be right. Why should he have learned from them and not directly from God? Maybe, he even asked Him to get an answer. The answer is written down in the Quran in various passages, admonishing,
- To pray only to God, and not to Jesus and not to Mary
- Not to see God as one composed of three entities but only as One.
Those two teachings are interlinked, as I will explain later. Let us first read the most relevant passages:
They disbelieve those who say, “God is the Messiah the son of Mary.” But the Messiah himself said, “O Children of Israel, worship God, my Lord and your Lord. Whoever associates others with God, God has forbidden him Paradise, and his dwelling is the Fire. The wrongdoers have no saviors.” They disbelieve those who say, “God is the third of three.” But there is no deity except the One God. If they do not refrain from what they say, a painful torment will befall those among them who disbelieve. Will they not repent to God and ask His forgiveness? God is Forgiving and Merciful. The Messiah son of Mary was only a messenger, before whom other Messengers had passed away, and his mother was a woman of truth. They both used to eat food. Note how We make clear the revelations to them; then note how deluded they are.
And God will say, “O Jesus son of Mary, did you say to the people, `Take me and my mother as gods rather than God?'“ He will say, “Glory be to You! It is not for me to say what I have no right to. Had I said it, You would have known it. You know what is in my soul, and I do not know what is in your soul. You are the Knower of the hidden.
O People of the Scripture! Do not exaggerate in your religion, and do not say about God except the truth. The Messiah, Jesus, the son of Mary, is the Messenger of God, and His Word that He conveyed to Mary, and a Spirit from Him. So believe in God and His messengers, and do not say, “Three.” Refrain—it is better for you. God is only one God. Glory be to Him—that He should have a son. To Him belongs everything in the heavens and the earth, and God is a sufficient Protector.
Now, the "Trinity" does not include Mary but the Holy Spirit.
The Holy Spirit is - as to the Quran, the Hadith, the Gospel and the Torah - described as an intermediate between humans and God. Through this Spirit we see God. It is not completely false to see the Holy Spirit as a part of God; so to say the part or God we can see and perceive. This does not put into question that God is One. It is also uncommon that Christians pray to the Holy Spirit instead of God. This is probably why the answer of the Quran does not concern the Holy Spirit admonishing not to say that God and the Holy Spirit are One.
Instead, the Quran admonishes not to see Jesus as a (partial) God and not to pray to Jesus, and not to say that Mary is the Mother of God and to pray to her. But such was and still is the custom among many Christians - although also according to the Gospel writings, Jesus did not teach to pray to him or to his mother but taught to pray to God.
It is this kind of worship to Jesus, who is the Messiah and a true Messenger of God but not God, and to Mary, who is a honourable woman but not a mother of God that is taught to be an error.
So, the question may have parted from the not-understanding of the trinity dogma; the answer comes to the actual weak point of the practise and believe which does not concern the Holy Spirit but - in addition to the trinity dogma - the worship to Mary.