Federer looked off colour from the start and only scored six more points than his Italian opponent who is ranked only 101 in the world.
The Swiss Masters produced a number of sublime winners during the contest but far more unforced errors as he was broken three times by his unheralded opponent.
He also blew two match points in the deciding tie-break before eventually winning it 8-6.
Monte Carlo Masters
Nadal claims first serve the key
"I knew it was going to be very hard because I haven't played on clay in over 10 months," he told Sky Sports after the game.
"I'm just happy to go through because the conditions were very tough out there and there were so many bad bounces.
"For me moving to clay is a tough change because it is slippery and slidey."
Next up for Federer will be Korea's Hyung-Taik Lee who beat Mikhail Youzhny 6-4 6-3 in a surprise result.
Despite a first-serve percentage of 46% and no aces, Lee restricted the Russian to two breaks, while winning five of his own on the way to victory in 94 minutes.
Andy Murray was forced to withdraw which meant that Guillermo Garcia-Lopez was the lucky loser who took his spot.
READ MORE: Murray forced to withdraw
Garcia-Lopez needed to beat Marc Gicquel to get any ranking points out of the event and he duly obliged with a 6-4 1-6 6-3 victory.
Kristof Vliegen saved four matchpoints and came back from a set down to defeat Marat Safin, and set up a third round clash with Rafael Nadal.
Safin produced near flawless tennis in the first set but too many of his groundstrokes went astray in the second, and Vliegen showed remarkable resolve to come back from 6-3 down in the tie-break and force the match into a decider.
Safin responded well, gaining a break in the opening game of the third set, but again lost his way, and inconsistency off the ground allowed Vliegen to break back, before sealing a 0-6 7-6 6-4 victory.
Meanwhile in the first round, Richard Gasquet won a marathon contest with Fernando Verdasco 7-5 6-7 7-6
There were flashes of brilliance in the match but in truth, both players did their best to throw it away.
Verdasco was 5-3 up in both the first and second sets but went on a five game losing streak which saw him lost the first set, and then he only won the second set 14-12 in a tie-break after saving five match points.
The third set again swung back and forth before Gasquet finally took the match 7-3 in the final tie-break as he took the match on his sixth match point.
The match took nearly three hours and 20 minutes to complete, there were 13 breaks of serve, and the two players both won an incredible 138 points.
"I ran out of gas in the second set and I have to say the Davis Cup defeat against Russia hurt me a lot," Gasquet said afterwards.
"But it is a beautiful tournament here and I had no choice but to win this match."
11th seed Gasquet will need to improve his performance if he is to beat Dominik Hrbaty in the next round - he got just 54 % of his first serves in and also fired 10 double faults.
Hrbaty, who reached the final of the Paris Maters last year, just edged out Albert Portas 7-5 7-6.
Clay court specialist David Ferrer moved into the second round with an easy 6-3 6-1 win over Gilles Simon.
The Spaniard, seeded 12, used his powerful forehand and baseline play to roll past the Frenchman and broke on six occasions during the match.
Ferrer broke in the third game of the first set and the second game of the second which meant he was always in control and he will now play another Frenchman, Julien Benneteau, in the next round.
"I felt really good from the start, which explains why the win was wrapped up quickly," Ferrer said after the match.
Nicholas Almagro retired while 5-0 down in the opening set of his match with 10th seed Tomas Berdych.
Benjamin Becker also moved into the second round as he beat former Australian Open winner Thomas Johansson 7-6 6-2.
Philipp Kohschreiber won 6-2 5-7 6-4 against Romania's Andrei Paval and he will now play David Nalbandian in the second round.
Nicolas Massu came from a set down to beat Filippo Volandri 4-6 7-5 6-3
In something of a surprise, Sergio Roitman came back after losing the first set to defeat Juergen Melzer 3-6 6-1 6-4.
Monte Carlo Masters
Fed: Rafa forces me to improve
Monte Carlo Masters
Nadal wins third Monte Carlo title