A spending bill to avert a partial government shutdown narrowly cleared a key procedural hurdle in the Senate.