Murray, three times a semi-finalist, wore down France’s world number 164 Mathias Bourgue, who had never won a tour-level match before this week, 6-2, 2-6, 4-6, 6-2, 6-3 and goes on to face 37-year-old Ivo Karlovic for a place in the last 16.
After coming back from two sets to love down to beat Radek Stepanek, also 37, in the first round in a tie played over two days, the British star had looked down and out once again on Wednesday.
After pocketing the third set, 22-year-old Bourgue, reduced to tears by the end, had break points for a 1-0 lead in the fourth.
But once they were squandered, the Frenchman’s challenge quickly wilted as the physically stronger Murray raced away with 12 of the last 15 games.
“He was excellent today. He dictated the points and made me run. He’s going to have a fantastic future,” said Murray after escaping what would have been his worst loss at the majors since a first round exit at the 2008 Australian Open.
“At the end of the third set, I just thought ‘what happened?’. I was 6-2, 2-0 ahead. He was then unbelievable and I found it hard just to win points.
“But I have played these matches many times. I just tried to fight through.”
As an indication of his struggles, Wednesday was the first time snce the US Open in 2005 that Murray had played two successive five-set matches at the Slams.
Karlovic, the 27th seed, defeated Australian wildcard Jordan Thompson 6-7 (2/7), 6-3, 7-6 (7/3), 6-7 (4/7), 12-10 in a four and a half hour marathon, unleashing 41 aces and 102 winners.
Karlovic is the oldest man in the French Open third round since 38-year-old Jimmy Connors in 1991.
Defending champion and third seed Stan Wawrinka defeated New York-born Taro Daniel of Japan 7-6 (9/7), 6-3, 6-4 and goes on to face France’s Jeremy Chardy.
“When you play a French player in Paris, it is always a bit different because the French are at home,” said Wawrinka of Chardy who he has beaten all four times they have met.
Japan’s fifth seed Kei Nishikori, a quarter-finalist in 2015, coasted into the last 32 with a 6-3, 6-3, 6-3 victory over Russia’s Andrey Kuznetsov.
Nishikori, the 2014 US Open runner-up, goes on to face former world number seven Fernando Verdasco of Spain.
Australian 17th seed Nick Kyrgios needed just 70 minutes to beat Dutch lucky loser Igor Sijsling 6-3, 6-2, 6-1.
– Kyrgios, Gasquet meet again –
He will now meet French ninth seed Richard Gasquet who defeated fellow former boys champion Bjorn Fratangelo of the United States 6-1, 7-6 (7/3), 6-3.
Gasquet and Kyrgios have met at the last two Wimbledons with the Australian saving nine match points in 2014 before losing a controversial rematch last year when he was accused of ‘tanking’ a game.
In the women’s event, Spanish fourth seed Garbine Muguruza defeated French wildcard Myrtille Georges 6-2, 6-0 and next tackles Belgium’s Yanina Wickmayer.
Sixth seed Simona Halep, the losing finalist to Maria Sharapova in 2014, came back from 4-1 down in the first set to beat Zarina Diyas of Kazakhstan 7-6 (7/5), 6-2.
Halep, 24, will next face Japan’s Naomi Osaka, the world 101 who has reached the third round at a major for the second successive time having also enjoyed a run to the last 32 in Australia.
Osaka, 18, knocked out 34-year-old Mirjana Lucic-Baroni 6-3, 6-3 which would have been a relief to Halep who lost to the world number 52 Croatian at the French Open last year and US Open in 2014.
Petra Kvitova, the 10th seed, saw off Taiwan’s Su-Wei Hsieh 6-4, 6-1 in a much more comfortable outing than her opener against Danka Kovinic where she had been just two points away from defeat.
Kvitova, a semi-finalist in 2012, next faces Shelby Rogers of the United States.
Russian 13th seed Svetlana Kuznetsova, the 2009 champion, was too strong for Britain’s Heather Watson winning 6-1, 6-3.
Kuznetsova will now face Fed Cup teammate Anastasia Pavlyuchenkova who saw off Cagla Buyukakcay, the first Turkish woman to win a match at a Grand Slam, 6-3, 4-6, 6-1.
Later Wednesday, Canadian eighth seed Milos Raonic takes on France’s Adrian Mannarino.
Women’s second seed Agnieszka Radwanska, a quarter-finalist in 2013, has a tricky assignment against Frenchwoman Caroline Garcia who won the Strasbourg title at the weekend.