Slovenia forward Marko Pajic had made four of his nine 2-point shot attempts before scoring the winning basket, 12 seconds from the final buzzer
Slovenia were seconds away from finding themselves on the wrong side of an upset against Sweden, but the hosts of the U20 European Championship managed to squeeze out a 70-69 victory, to improve to 2-0.
They only escaped after Marko Pajic made an open shot from under the basket with 12 seconds left on the clock.
After going 1-of-5 from beyond the arc, Marcus Eriksson hit a clutch three-pointer with 49 seconds to the final buzzer to give Sweden a 69-65 lead.
However, Klemen Prepelic answered with a triple of his own before Pajic made the game-winner on the next possession.
Eriksson had a chance to give Sweden the victory with a mid-range jumpshot at the buzzer, but the ball bounced off the rim.
Alen Omic finished the game with 24 points and five rebounds, Prepelic had a great all-around performance with 13 points, eight rebounds and five assists, while Pajic chipped in with 11 points and eight boards.
Jonathan Person had 20 points and eight rebounds for Sweden, while Eriksson still collected 14 points despite a tough shooting night.
On Saturday Slovenia will take on Lithuania while Sweden, currently at 0-2, will need a win against Italy to maintain any chances of reaching the Qualification Round.