Borussia Mönchengladbach took the Rhine derby bragging rights to move two points clear of the relegation zone.