Brazilian forward Igor scored the first goal in the 23rd minute but Gambia bounced back with a goal in the 27th by Abdoulie Mansally.
Gambia sealed its win with a penalty goal from Ousman Jallow in the 75th after Momodou Ceesay leveled the scores in the 45th.
Brazil had Marcelo and Celso sent off while Gambian defender Ebrima Sohna was also ejected.
Gambia and Brazil share Group D with the Netherlands which defeated Qatar 5-3.
In Group C the United States defeated North Korea 3-2 and Italy beat Ivory Coast 4-3.
Midfielder Ryan Soroka scored the first goal for the United States in the 13th minute followed by a goal from Kyle Nakazwa in the 43rd. Striker Preston Zimmerman scored the winning goal in the 72nd.
North Korean midfielder Myong Ho Choe scored his team's first goal in the 24th minute and Kux Jin Kim scored in the 86th.
Italy's Christian Tiboni scored in the 21st and 32nd minutes before Matteo Mandorlini found the net in the 86th and Salvatore Foti claimed a goal a minute before fulltime.
Alassane Diomande scored for the Ivory Coast in the 27th minute Ismael Fofana in the 53rd and Koffi Kouassi in the 87th.
In Piura the Netherlands' high-scoring defeat against Qatar saw two goals from Marvin Emnes in the 6th and 84th and one goal each from Jordy Buijis in the 30th Mike Van Der Kooij in the 58th and John Goossens in the 65th minute.