Switzerland could hardly have got off to a better start after the lively Innocent Emeghara was brought down by defender Henri Ndong inside the penalty area and Colombian referee Wilmar Roldan pointed to the spot after five minutes.
Mehmedi sent goalkeeper Didier Ovono the wrong way, only to see Mr Roldan order the kick to be retaken because of encroachment. And although the Dynamo Kiev man shot to the other side, the result was the same.
Gabon endured a difficult start to the game as their defence was repeatedly breached, but having hit the crossbar through Jerry Obiang, they responded when Aubameyang converted Alexander Ndoumbou's cross from close range.
Aubameyang perhaps should have doubled his tally after the break, but he headed Levy Madinda's 63rd-minute corner straight at goalkeeper Diego Bengalio, and Ovono did well to keep out substitute Pajtim Kasami's drive six minutes later.
Fabian Frei for Switzerland and then Ndoumbou for Gabon might have snatched victory as time ran out, but the Swiss finished with 10 men after midfielder Oliver Buff was dismissed for a second yellow card.