Republicans avoid shutdown by cutting deal with Democrats over their own party’s hardliners