Paul wrote in 1 Corinthians 14:14-15...
For if I pray in a tongue, my spirit prays, but my understanding is unfruitful. What is the conclusion then? I will pray with the spirit, and I will also pray with the understanding. I will sing with the spirit, and I will also sing with the understanding.
Praying 'with the spirit' means to 'pray in a tongue.' When a person does this, his 'understanding is unfruitful.' In other words, he cannot understand what he is praying because he doesn't understand the language. The same is true when singing with the spirit. This means singing in a tongue (a language).
In 1 Corinthians 14:2 and 4 Paul wrote, 'For he who speaks in a tongue does not speak to men but to God, for no one understands him; however, in the spirit he speaks mysteries... He who speaks in a tongue edifies himself....' When we pray or sing in a tongue, we may not understand what we are saying, but we are nevertheless building ourselves up spiritually.
This is why Jude wrote, 'But you, beloved, building yourselves up on your most holy faith, praying in the Holy Spirit...' (v.20).