The 27-year-old Portuguese international underwent a magnetic resonance on Friday before training which detected the injury, it said in a statement posted on its web site.
"He will miss four weeks and will be monitored for improvement," it said.
Pepe came on for Ricardo Carvalho in the 47th minute of Real's 2-0 defeat in the Spanish Cup on Thursday in their return match at Levante.
But despite the loss Real, cushioned by an 8-0 first leg lead, pushed through to the quarter-finals of the tournament 8-2 on aggregate.
Short link: