Pepe lies in pain on the Mestalla Stadium pitch in Valencia. ((Javier Soriano/AFP/Getty Images) )

Portugal defender Pepe has undergone surgery on his injured right knee, and his doctor says the Real Madrid player may recover in time for the World Cup.

The Brazilian-born Pepe had the operation Thursday in Porto, Portugal. Surgeon Jose Carlos Noronha said Pepe will remain in the hospital for two days before starting a recovery program that is expected to last for months.

Noronha said Pepe, who was a standout player in Portugal's qualifying campaign, could be fit before Portugal's opening World Cup match against Ivory Coast on June 15.

Pepe twisted his right leg while playing a Spanish league game last weekend.