The Senate on Thursday voted overwhelmingly to impose a labor agreement between rail companies and union workers who have been locked in a stubborn stalemate, moving with uncommon speed to avert a potential Christmas season rail strike poised to jeopardize shipping across the country.