Poor marking allowed substitute Jerome Ramatlhakwana to sink in the winner in the fourth minute of added time after an own goal by Edwin Olerile levelled matters in the 87th minute.
In truth, Stars deserved what they got in a limp display in a match where Lemponye Tshireletso put Botswana ahead with a brilliantly floated free-kick in the 12th minute.
Needing victory to advance to the quarterfinals against regional giants Angola, Stars coach Adel Amrouche made two changes to the line-up that beat Swaziland 2-0 bringing on Andrew Murunga and Musa Mohammed to start.
With Stars struggling to establish any rhythm in the opening minutes, Botswana went ahead when Tshireletso curled the ball past Jerim Onyago in the Stars goal for the opener.
Amrouche made a tactical switch minutes afterwards bringing on AFC Leopards’ Edwin Seda for Mohammed but the substitituion failed to spark his team as they went in to the break trailing 1-0.
The Belgian coach then turned to Gor Mahia’s Paul Mungai Kiongera, who has been in a rich vein of form of late and Leopards winger Paul Were in the second half in a bid to refresh his sides’ attack in the second half.
Although Stars improved as a forward going force, it was Botswana who looked comfortable with few chances on the break as Were, Kiongera, Francis Kahata and Edwin Lavatsa upfront failed to string together cohesive movement.
With time running out, Kenya got a lifeline when Olerile headed the ball into his own net in almost comical fashion under pressure from defender David Owino who was chasing down a long punt from defence.
Stars needed another goal to advance since Lesotho were leading Swaziland 2-0 but instead of a late flourish, they were hit by a sucker punch winner when the defence stood still as a long free-kick was floated in the box from the left.
Ramatlhakwana, unmarked, headed the ball past Onyango to confirm Stars exit but victory was hollow for Botswana since they also lost to Lesotho in the race to top Group B on goal difference.
It was the first time for Stars to feature in the Southern African regional showpiece on invitation and are expected back home from Friday.