The 27-year-old sustained the injury in Bayern's Liga Total Cup semi-final defeat to Werder Bremen last Saturday.
The world-renowned Hans-Wilhelm Muller-Wohlfahrt has revealed that Gomez underwent a successful surgery on Tuesday.
"The surgery went very well," he said in a statement on the club's website. "Mario has to rest for three weeks and then start rehabilitation training."
The German international said that he was no longer in pain following the operation and he is now looking forward to getting back in action.
"I am relieved the surgery went well and I am no longer in pain," said Gomez. "I need to be patient now, but will do everything I can to be back on the pitch as soon as possible."
Gomez joined the Bavarian giants from Stuttgart in 2009.