A bipartisan Senate amendment to withdraw the remaining 8,600 U.S. troops from Afghanistan—ending a bloody war that has dragged on for nearly two decades—failed Wednesday after 16 Democrats joined 44 Republicans in voting to table the measure, effectively guaranteeing it will not be included in the chamber’s $740.5 billion National Defense Authorization Act.