A slim majority of union members approved three-year contracts that end a confrontation that had put the industry on the brink of a strike.