Case Keenum passed for 185 yards and was picked off once after completing 20- of-42 passes for the Texans (8-7), who guaranteed themselves at least a .500 season with their third win in the last four.
Foster also racked up a game-high 96 yards rushing on 25 attempts while C.J. Fiedorowicz was the beneficiary of his scoring throw. Andre Johnson totaled 65 yards on six catches and reached the 1,000-reception plateau.
Joe Flacco had one of his worst days as a professional, completing only 21 of his 50 passes for 195 yards, two touchdowns to Torrey Smith and three interceptions for the Ravens (9-6), who had a two-game win streak snapped.