The seven-times champion enjoys too much deep-rooted affection at the All England Club to be cast as a real pantomime villain, but for once the cheers were all behind the 25-year-old local hero on the other side of the net.
Federer's 81st Wimbledon match, of course, ended in victory.
Even the most over-egged Hollywood script could not have had him losing to world number 772 Willis, whose transformation from a 30 pounds ($40.30) an hour tennis coach to Wimbledon sensation has captured the imagination of the sporting world.
But the swaggering Swiss was at least made to break sweat under the closed roof before claiming a 6-0 6-3 6-4 victory.
Willis had his photo taken with Federer, 34, before the warm-up and could hardly stop grinning.
He even celebrated a practise serve with a raised fist as his friends went through their song-list at court side.
But when Willis lost the opening set in 25 minutes without managing a game you feared the worst.
So when he did finally trouble the scoreboard, holding serve in the eighth game, the deafening roar rivalled the one heard when fellow Briton Andy Murray ended 77 years of pain by beating Novak Djokovic in the 2013 final.
From then on the quirky left-hander's unorthodox shots kept 17-times major champion Federer guessing at times, especially his grass-hugging backhand slices and cheeky drop volleys.
Federer joined in with some dazzling party pieces of his own but played largely within himself -- smiling occasionally as Willis bathed in an unfamiliar spotlight.
Afterwards he paid Willis the ultimate compliment.
"I'll remember most of the Centre Court matches here at Wimbledon, but this one will stand out because it's that special and probably not going to happen again for me to play against a guy 770 in the world," Federer told reporters.
"The support he got, the great points he played. In some ways, I enjoyed it as much as I possibly could, but I also had to put my head down and focus hard to get the lead."
Federer broke for a 5-2 lead in the second and closed it out two games later but was pushed harder in the third as Willis, who survived six qualifying rounds before stunning Lithuania's Ricardas Berankis in round one, kept his nose in front.
Federer, moving well after missing the French Open with a back injury, looked a touch relieved when he broke at 4-4 in the third set, though, and claimed victory when Willis sliced a backhand long in the next game.
"Today again, after the match, I just said he played great and I wished him the best for the rest of the year," Federer said. "I said a few days ago, this story is gold."
Willis, cheered on by his parents and his girlfriend who persuaded him to continue his professional career rather than coach in the U.S., walked off with his head held high.
His mates sang "Shoes off, if you love Willis! -- a bizarre chant they started when he was beating 54th ranked Berankis.
"I have had a fantastic couple of weeks. I will keep going and do what I have been doing," said Willis. "There is life after Wimbledon and I want more experiences like this. I've earned myself a beer now!"
($1 = 0.7445 pounds)