Everton midfielder Gueye struck on 70 minutes, side-footing the ball into the net from close range after being set up by Liverpool star Sadio Mane.
This was the first Cup of Nations match to use the VAR (video assistant referee) system and there were no controversial incidents.
Benin were reduced to 10 men in the closing stages when Olivier Verdon was given a straight red card for a last-defender foul.
Senegal coach Aliou Cisse made one change to the team that defeated Uganda to reach the last-eight stage with Keita Balde replacing fellow forward Ismaila Sarr.
Benin boss Michel Dussuyer changed three of the team that shocked Morocco after a penalty shootout to reach the quarter-finals for the first time.
Khaled Adenon missed out due to a suspension and Seibou Mama and Jodel Dossou were benched with Seidou Baraze, Sessi D'Almeida and Steve Mounie taking their places.
This was only the third time the countries met in a competitive match with Senegal winning 1-0 at home and drawing 1-1 away in 2002 World Cup qualifying.
Senegal applied most of the early pressure with Benin content to sit back and soak it up before a small crowd at the 30,000-capacity 30 June Stadium in the Egyptian capital.
But the first scare for Benin was self-inflicted as goalkeeper Owolabi Kassifa fumbled a weak shot and had to swiftly regain possession as Mane darted forward.
Mickael Pote, the veteran Benin forward who bagged a brace in a group draw with Ghana, came agonisingly close to putting the Squirrels ahead midway through the opening half.
He cleverly backheeled a free-kick driven low into the box and the ball flew just wide with goalkeeper Alfred Gomis beaten.
A free-kick at the other end offered Kalidou Koulibaly a chance to break the deadlock, but he narrowly failed to connect with the ball after it eluded the defensive wall.
There was intense Senegal pressure as the opening half drew to a close with Verdon coming to the rescue by clearing a Henri Saivet cross.
Verdon and his fellow defenders then blocked three close-range attempts by the Teranga Lions to end the stalemate before the break.
Senegal did get the ball in the net nine minutes after half-time, but the Algerian referee blew for offside and VAR confirmed that his decision was correct.
A howler from Gomis nearly gifted Benin a mid-second-half lead as he miscued his clearance of a back-pass and the ball trickled just wide of the goal.
Soon after, Senegal were rewarded for their dominance of possession and territory when Gueye burst into the box and fired over Kassifa.
Benin were lucky not to fall further behind in the following few minutes as Senegal had a shot cleared off the line and Mane was denied by a marginal offside call.