Yohan Cabaye missed a penalty soon after Townsend's goal in a game he and manager Alan Pardew would rather forget against their former club.
Fresh from the FA Cup semi-final victory over Watford, Pardew made just one change to the Palace side from the game at Wembley Stadium with James McArthur replacing Wilfried Zaha. The Scotland midfielder was starting for the first time since suffering an ankle ligament injury in February.
Frantic, yet frustrating, first-half ends goalless
Midfielder Jason Puncheon had Palace's first chance of the game, volleying a Pape Souare cross wide of Karl Darlow's goal, while Scott Dann had to make a last-ditch tackle to deny Papiss Cisse a seemingly certain goal at the other end.
The frantic start to the game was typical of two sides desperate to stay clear of the relegation zone, but the Eagles edged the best spells of the early exchanges and Connor Wickham - scorer of the winning goal at Wembley - had to be denied in front of goal by the excellent Jamal Lascelles.
Palace's other goal scorer at Wembley, Yannick Bolasie, let fly from long-distance and the ball travelled just wide of Darlow's goal. Magpies defender Chancel Mbemba then had a similar effort which Wayne Hennessey held with ease.
Rafael Benitez's side had their best spell of the half in the final five minutes of the first period, and the half culminated with Jack Colback curling just wide of goal from the edge of the penalty area.
Despite both sides having good opportunities to take the lead, the first-half summed up both sides' seasons as they failed to find the net.
Townsend goal steals the points for Magpies against lacklustre Eagles
Newcastle finally took the lead fifteen minutes into the second-half when Dann fouled Townsend in a dangerous position outside the penalty area. The Magpies winger took the free-kick himself and it curled past Hennessey and into the far corner of the goal.
Newcastle had been the better team in the opening stages of the second period and the goal appeared to give the whole of St. James' Park a lift as Benitez's side seeked a second goal.
Palace then had the chance to level the score when referee Mike Dean awarded a penalty having spotted a handball following a corner. Cabaye stepped up against his former side, but Darlow pulled off a magnificent save from the Frenchman's penalty - much to the delight and relief of the St James' faithful.
Palace responded to the set-back by replacing Wickham and Puncheon with Emmanuel Adebayor and Dwight Gayle as the Eagles searched for a late equaliser deep into the second-half.
As the clock ticked down, Cabaye had another effort, this time a half-volley, which sailed high over the bar on a day he would probably rather forget against the club he left in controversial fashion to join French Ligue 1 giant Paris Saint Germain.
Despite the Eagles throwing all ten outfield players further forward in added-time, Newcastle remained resolute and secured their first win in three games.
Palace still appear to be safe for now, but fellow relegation rivals Sunderland took a point at Stoke City, which means Cabaye's penalty could prove costly come the end of the season.
The Eagles' performance was frustrating and almost typified their form since December; Pardew's side dominated the first-half but another poorly conceded goal means they walk away from yet another relegation rival without a point.