Because someone could say: inasmuch as prayer in a tongue is without fruit to the mind, but the spirit prays, should one then not pray in the spirit. Therefore, the Apostle answers this objection, saying that one should pray in both ways, in the spirit and in the mind; because man should serve God with all the things he has from God. But from God he has spirit and mind; therefore, he should pray with both: "With all his heart he will praise God" (Sir 47:8). Therefore, he says: I will pray with the spirit and I will pray with the mind also; I will sing with the spirit and I will sing with the m...ind also. And so he says that he will pray and sing; because prayer is the beseeching of God, and so he says, I will pray, or it is praising Him, and so he says I will sing. Concerning these two Jas (5:13) says: "Is anyone among you suffering? Let him pray. Is any cheerful? Let him sing." "Sing praises to the Lord" (Ps 9:11). I will pray, therefore, in the spirit, i.e., imagination, and with the mind, i.e., the will.
Source: Commentary on 1 Corinthians