Granada took advantage of Barcelona's troubles on the road to move top of LaLiga with a 2-0 victory at the Estadio Los Carmenes.
Ernesto Valverde wasted no time at the start of the second half, introducing both Messi and Ansu Fati for Perez and Junior Firpo.
Granada, meanwhile, are the surprise package in La Liga and the win takes them top following their promotion from Segunda.
Ramon Azeez headed in at the back post with less than two minutes played.
Granada had a great chance to double the lead after 14 minutes as Antonio Puertas cut inside from the flank before unleashing a curling effort that forced Marc-Andre Ter Stegen into a superb save.
Barcelona's best opportunity fell to Luis Suarez in first-half stoppage time, but the Uruguay forward's goal-bound attempt was - typically of the hosts' defensive performance - blocked on the line.
The goalkeeper, under no pressure at all, dropped a catch before recovering to smother the ball before it went over the goal-line.
However, it was Granada that would score again when a handball in the penalty area was called on Arturo Vidal and Alvaro Vadillo converted from the spot after a consultation with VAR confirmed the ruling.
Messi tried in vain to haul Barcelona back into the game, sending in numerous crosses that came to nothing and having a shot saved by Rui Silva.
"This defeat hurts us and makes us very anxious and we need to really take a hard look at ourselves if we are to improve", Barca's Luis Suarez said after a second defeat in five league games confirmed the club's worst start since the 1994/95 season.