Rwanda beat Djibouti 5-2 in their final Cecafa Cup group game to qualify for the quarter-finals with maximum points.
In the day's other game, Ethiopia drew 1-1 with Malawi, a result which qualifies Malawi for the next round.
Ethiopia though are out of the tournament, being unable even to grab one of the spots for the best-performing third-placed teams.
Rwanda put out a weakened side for their match with Djibouti and struggled against the minnows.
At half-time Djibouti were 2-1 up and Rwanda Coach Milutin "Micho" Sredrojevic brought on a number of senior players in response.
The ploy worked, as captain Olivier Karekezi scored a hat-trick to win the game.
The game started at cracking pace and Rwanda took the lead three minutes in, thanks to a brilliant run and finish from Kamana Bokota Labama.
But that served only to bring Djibouti into the match and they equalised on 25 minutes through Daoud Ahmed Hassan, who capitalised on a defensive mix-up by Rwanda.
Djibouti then took the lead 12 minutes later, thanks to a goal from Warsame Muessa.
Half-time brought wholesale changes from Rwandan coach Micho, and the Amavubi were level again 12 minutes into the second half when Jean-Baptiste Mugiraneza headed home.
Then came Karekezi's turn to shine.
He restored the lead with a powerful low shot from outside the area in the 77th minute and extended the advantage two minutes later.
He completed his hat-trick five minutes from time - a thrilling performance to justify his return to the squad after a year.
The other two teams in Group A, Tanzania and Zimbabwe - who are guests at the East and Central African regional tournament - will play on Saturday.
In Group C, the other guests at the competition, Malawi, booked their place in the last eight with a 1-1 draw with Ethiopia.
Ethiopia, who needed a win to stay in contention in the tournament, opened the scoring on 15 minutes but four minutes later, the Flames of Malawi were level.
There were no further goals and the result ends Ethiopia's interest in the tournament.
But Kinnah Phirri, who is coach of Malawi, has now revised his ambitions.
"My target was a quarter-final but now it is to reach the semi-final - we came into the game wanting to win but the draw is okay since it enabled us qualify," he told the BBC.
Sudan take on Kenya on Saturday in the remaining group match in this pool.