Sterling has been sidelined with a damaged hamstring after breaking down in the final minutes of City's 2-0 defeat at Tottenham last weekend.
Guardiola insists he has no idea how long the England ace will be sidelined for and fears he will not be available for the trip to the Bernabeu later this month.
The City boss even refused to rule out Sterling being absent for months - and the news could be a huge blow to his chances of landing the Champions League for the first time since taking charge at the Etihad in 2016.
Leroy Sane has returned to training with the first team, having been sidelined since August with damaged knee ligaments, but is not expected to be in contention for several more weeks.
Guardiola said: “It is his hamstring and we will see. It takes weeks, but we'll see if he's back for the Leicester game or Real Madrid.
“Weeks or months? I don't know. It's a problem, but it's a problem we had with others like [Ilkay] Gundogan and [Aymeric] Laporte this season for four or five months.
“It's what it is. It's a problem with this kind of season, particularly for the players.”
City have been linked with signing Messi, who has a clause in his contract allowing him to leave the Nou Camp for nothing this summer.
Guardiola added: “He's playing for Barcelona and he will stay there. That's my wish. I'm not going to talk about players for other clubs, but I think he will finish his career there.”
City confirmed on Twitter that Sterling will not be fit for Sunday’s clash with West Ham on Monday night.
“Raheem Sterling will miss our game against West Ham this weekend after scans revealed he has suffered damage to his left hamstring," the club tweeted,” they said.
“Everyone at City wishes @sterling7 a full and speedy recovery.”