The Galashiels side’s tries were scored by Taylor Wilson, Angus Dun, John Turnbull and Fergus Johnston, with Craig Dods adding three conversions.
Bradley McNamara, Connor Slader and Ian Reid scored tries for the visitors, with Fraser McKay converting all three.
Reviewing Saturday’s win, Gala head coach Fraser Thomson told Borders Rugby TV: “Dundee have got better and better. They’ve got a good group there, and they pushed us all the way.
“We were good in spells and not so good is spells but we managed to get over the line. It’s not perfect but we just keep ticking them off as much as we can.
“Our end goal is to be where we believe Gala should be. So far, we’re there or thereabouts, but we’ve still go nine games to go, so I’m not counting any chickens yet.”
That victory against 10th-placed Dundee leaves Gala sitting third in the table with 53 points from 13 games. That’s two points behind second-placed Biggar and five behind league leaders Heriot’s Blues, but the Netherdale team have got a game in hand on the former and two on the latter.
Kelso are fourth with 46 points from 16 games and Melrose sixth with 45 from 14.
Keith Melbourne scored Kelso’s only try in South Lanarkshire, with Dwain Patterson adding a conversion and a penalty.
“It’s one of the toughest places to come in Scottish rugby,” said visiting skipper Andy Tait.
“The way Biggar’s form’s been last season and coming into this season, obviously they’re mounting a title challenge, but I felt we had enough to win that game.
“Some basic errors ultimately cost us the game. Today just wasn’t our day.”
Melrose’s try-scorers were Richard Ferguson, Gavin Wood twice, James Brown, Matthew Klein, Jack Dobie and Finn Douglas, with Struan Hutchinson converting four.
Melrose host fifth-placed Highland this coming Saturday, January 29, with kick-off at 3pm, but both Gala and Kelso are away in Edinburgh. Gala play second-bottom Watsonians at 3pm and Kelso play Heriot’s Blues an hour earlier.