The 27-year-old, also known as Koka, came off the bench to make a significant impact for Pedro Martins’ men at Karaiskakis Stadium.
Summer signing and French-born Senegalese Pape Gueye started for Marseille while Dario Benedetto, Florian Thauvin and Dimitri Payet formed a three-man attack.
The first half was cagey, as both sides struggled to open the scoring and wasted a number of chances before the break.
The best opportunity fell in the way of El Arabi who got to the end of a cross but failed to connect firmly as his effort was cleared by Marseille defenders.
The second-half saw more goal-mouth action and Olympiacos thought they had broken the deadlock in the 52nd minute when Giorgos Masouras found the back of the net but his effort was ruled out for offside.
In an effort to turn things around, both sides made a number of changes, with the Red and Whites introducing Konstantinos Fortounis for Lazar Randjelovic and Mahgoub replaced Masouras in the 84th minute while Senegal’s Pape Cisse was brought on for Mathieu Valbuena.
Six minutes after his introduction, the Egypt international scored the all-important winning goal after he was set up by Mathieu Valbuena.
Ba featured for the duration of the game while Gueye made way for Kevin Strootman with five minutes left to play.
Mahgoub will hope to continue his impressive form in front of goal when they take on FC Porto in their second Group C game on October 27.Africa Cup of Nations