Party leaders were able to muscle through considerable internal rifts, but the bill’s fate in the House was uncertain.