England were dumped out of the ICC Champions Trophy after suffering a dramatic eight-run defeat to Afghanistan in what effectively amounted to an eliminator between the sides in Lahore.