Real Madrid boss Carlo Ancelotti has revealed that Pepe came close to departing Los Blancos in the summer.
Pepe, who has been one of Madrid's most impressive performers this season, scored the winner in Sunday's 1-0 win over Espanyol in Barcelona in La Liga.
"I think Pepe is having a very good season. At the beginning [of the season], he was hesitant about staying but decided to after I told him he was important," he told reporters at a press conference.
"I'm satisfied with the game as the team has balance, played good football and has not taken risks. We cut the points gap and that was the objective.
"Everything has gone well. We started the game slowly and suffered in the first 15 minutes but after that we had many opportunities. After the goal we controlled the game well."
The Portuguese had previously been linked with Manchester City.