The visitors were the better team for long periods but it was Gallagher's strike which ultimately proved the difference at a sweltering Valley as promoted Charlton went second in the table.
Canos should have broken the deadlock two minutes later but instead headed over despite being completely unmarked.
Brentford continued to look dangerous and were unfortunate to see another Canos effort go close, this time the Spaniard placing an effort from just outside the box agonisingly wide.
Despite all their first-half dominance, Brentford fell behind four minutes before the interval from what was the Addicks' only real attempt on goal up until that point.
Purrington was well placed to block Henrik Dalsgaard's stoppage-time effort to ensure the hosts went in at the break with their advantage still intact.
Charlton looked much more threatening from the restart.
Gallagher placed a header straight at Raya early in the second half and Lyle Taylor was within inches of connecting with a dangerous Purrington delivery.
Brentford continued to look dangerous, however, and Phillips produced an excellent fingertip save from Watkins on the hour to preserve the home side's narrow lead.
Jason Pearce made a timely clearance to thwart Marcones at the expense of a corner and then Phillips gathered Dalsgaard's 63rd-minute header.
A well-worked Brentford attack ended disappointingly as Dalsgaard shot well over the bar from outside the area after 74 minutes.
Dalsgaard's frustration was compounded moments later when he picked up a yellow card for a foul on Taylor as the Addicks striker threatened to burst clear.
Phillips was alert to push away Mathias Jensen's 25-yard drive in the 85th minute and then Pearce produced yet another vital block again on Marcondes inside the box.
Brentford sent up keeper Raya for an injury-time free-kick and the ball fell to the unmarked Said Benrahma, whose effort sailed harmlessly behind.
There was more woe for the visitors when a trio of shots were blocked by Charlton's gallant defence.