Ray J is in bad shape, struggling to breathe as he battles pneumonia in a Miami hospital … it was so bad he thought he was going to die.

Ray J’s manager, David Weintraub, tells TMZ Ray went into the hospital 4 days ago and doctors learned from the jump he was battling pneumonia. David looped Ray in on the call and we spoke to him for several minutes, and it was apparent he wasn’t out of the woods.

Ray told us … when he was admitted doctors assumed he had COVID, so they placed him in the COVID wing of the hospital, which he said was frightening, telling us, “I thought it was over. I started praying and knew God is good so I just kept praying.”

He says he was given 5 COVID tests, all of which came back negative, and after 2 days he was moved out of the COVID wing.

Read more in TMZ.com