The midfielder struck after 69 minutes before Olivier Verdon was dismissed for Benin late on.
Senegal progressed in Cairo despite Sadio Mane having two goals disallowed for offside by VAR, which had been introduced for the quarter-finals.
Aliou Cisse's side will meet Madagascar or Tunisia in the last four on Sunday in Cairo as they try to win the competition for the first time.
Goalkeeper Alfred Gomis almost gifted Benin the lead when he miscontrolled a backpass and saw the ball go wide.
But Gueye won it with 21 minutes left when he ran from deep, swapped passes with Mane and fired in from 12 yards.
Verdon was then sent off with eight minutes remaining for a foul on Gueye.