The passage of the funding bill came hours before a shutdown, with Democrats under fierce pressure to oppose the measure.