Barca eventually break down gutsy Granada
Lowly Granada were organised and dangerous on the break and it was only after Victor Valdes had saved a one-on-one with Fabian Orellana in the 86th minute that Barca finally found a way past inspired visiting goalkeeper Tono.
Xavi cracked a shot in off the underside of the bar in the 87th and Messi's persistence saw him squirm into the area and strike a low cross that was turned into his own net by Borja Gomez in time added on.
"Every victory is important. Maybe we struggled more than on other days but we have to know how to get through these games," Barca full-back Dani Alves told Spanish television.
"It wasn't that we didn't play well, a lot of credit must go to our rivals. Their keeper has been superb and I have to congratulate him."
Barca coach Tito Vilanova opted to play midfielders Alex Song and Javier Mascherano at centre-back with Gerard Pique and Carles Puyol injured and the defence looked shaky at times.
With Andres Iniesta also injured and Xavi on the bench, Barca were not as fluid as usual and it was only after Xavi came on in the second half that they really got into their stride.
The pressure grew on the visitors' goal with Messi, Cesc Fabregas and David Villa, on his first start since breaking his leg last December, all going close.
Tono's work load was increasing when Granada's Orellana broke free to be denied by Valdes, and soon after Xavi struck the opener from the edge of the area.
Messi, who seemed bad-tempered and argumentative throughout, forced the second goal in a breathless last few minutes.
Real Betis rose to third with nine points after a thumping Paulao header earned a 1-0 home win over misfiring Espanyol.
The Brazilian defender connected with a free-kick after 18 minutes but his side failed to make the most of a second yellow card for Espanyol's Wakaso Mubarak in the 68th, and endured some worrying moments before securing the victory.
South Korea striker Park Chu-young scored with his first touch on his home debut for promoted Celta Vigo, leading them to a 2-1 victory over Getafe.
Park, who helped his country win bronze at the Olympic Games in London and joined Celta on loan from Arsenal on transfer deadline day three weeks ago, volleyed home in the 68th minute.
Celta had taken the lead in the 57th minute with a breakaway goal from Augusto Fernandez, only for Abdelaziz Barrada to level almost immediately after a well-worked move.
Park, who netted two minutes after coming off the bench, had the chance to score a second near the end but he pulled his shot wide with only the keeper to beat.
Celta's second win put them ninth in the standings with six points from five games, two places ahead of Real Zaragoza, who won 3-1 at home to bottom side Osasuna.
Osasuna finished seventh last season but have only taken one point from 15 this term and trail Espanyol who also have one point. But they did score the goal of the game at the Romareda with Emiliano Armenteros's run and shot after 29 minutes.