Trabzonspor moved to the brink of qualification to the Europa League knockout stages following a hard-fought 2-0 win at Legia Warsaw.