The Reds had looked on the verge of a frustrating defeat with five minutes remaining but the home-grown duo had other ideas. Gerrard's superb curler from the edge of the area won it after Carragher's deflected strike had cancelled out Mido's opener.
It was a positive end to a frustrating afternoon for the Reds who dominated for the majority of the clash but struggled to find a way past rookie stopper Ross Turnbull. But they will now head into the second-leg of their vital Champions League qualifier on Wednesday in buoyant mood after snatching victory from the jaws of defeat.
The visit of 'Boro marked the first match of the new season at Anfield and as supporters settled into their seats they were not just treated to their first glimpse of the likes of Robbie Keane and Andrea Dossena in competitive action, but they will also have noticed the new electronic advertising boards lining the perimeter of the pitch.
The game itself began at a frenetic pace and although the visitors looked lively in the early exchanges it was Liverpool who had the first real sight of goal when Dirk Kuyt brought a great save out of Ross Turnbull from 25 yards.
It was the ideal start for the keeper who had only been called into the starting XI at the last moment after Brad Jones injured his hand in the warm up.
The Reds were eager to test him at every opportunity but both Robbie Keane and Yossi Benayoun shot well wide of goal when provided with opportunities while Pepe Reina had to be alert to tip Andrew Taylor's 15th minute blockbuster over the crossbar.
The visitors were far from overawed by their visit to Merseyside and, buoyed by their opening day win over Spurs, they more than matched Liverpool with Stewart Downing in particular looking dangerous on the left.
It just wasn't happening for the hosts and after Torres saw his penalty appeals turned down by referee Mike Riley Steven Gerrard was next to hang his head in frustration after his arcing effort flew just wide of the near post.
As the half came to a disappointing end, fans will have been cheered by the sight of Keane combining brilliantly with Torres to set the Spaniard clear but Robert Huth did just enough to deny him a clear strike at goal.
It was something they hoped to see more of in the second period but as the clock ticked down the visitors' rearguard remained stubbornly resistant.
In fact, it was 'Boro' who manufactured the best opening of the game on the hour mark when substitute Mido broke down the left and fed the ball into Tuncay who produced an unorthodox turn to completely bamboozle Martin Skrtel before lashing his shot straight at Reina.
For Liverpool it was Torres who continued to look the more likely and he smashed a 25-yard thunderbolt just wide of the far post as he continued his bid to become the first player in Liverpool's history to score in nine successive home league games and break the previous record of eight set by Roger Hunt in 1961-62.
However, it was not to be El Nino's day and Rafael Benitez's men were stunned 20 minutes from time when Mido received a pass from Jeremie Aliadiere and fired a sweet 25 yard strike into the bottom right-hand corner to leave Reina with no chance.
It looked like Middlesbrough were on the verge of their first win at Anfield in 21 attempts but with time running out Carragher pulled them level with a speculative 25-yard effort that took a huge deflection off Emanuel Pogatetz.
And it got better for the Reds in injury-time when Gerrard seized on a loose ball on the edge of the area to curl home a magnificent winner and send the home support into ecstasy.
Liverpool: Reina, Dossena, Carragher, Skrtel, Arbeloa, Benayoun, Gerrard (captain), Alonso, Kuyt, Torres, Keane. Subs - Agger, Plessis, Aurelio, Ngog, El Zhar, Babel, Cavalieri