The Court of Arbitration for Sport said Jeglic, 29, tested positive for fenoterol, a banned substance that can be used to treat breathing difficulties.
Jeglic, who scored a tie-breaking penalty shot against Slovakia on Saturday, admitted taking the drug and agreed to leave the tournament before the 24-hour deadline to quit the Olympic Village.
“I take the mentioned drug due to asthma under medical advice,” the Slovenian said in a statement, adding he was tested on Friday.
“It has been prescribed to me after testing for respiratory problems in Slovakia in 2017. Unfortunately, I have forgotten to declare it as a therapeutic use exception.”
Slovenia went on to lose 2-1 to Norway on Tuesday, putting their hopes for a medal to an end.
“He’s a big part of our team,” Slovenia captain Jan Mursak said of Jeglic after the loss to Norway. “We were kind of disappointed and a little upset that he won't be able to play but we don't really know what the situation is.”
Russian curler denies doping charge
The case is the third positive test at the Games after a Japanese speed skater Kei Saito failed a pre-competition test and Russian curler Alexander Krushelnitsky tested positive for the banned substance meldonium.
Krushelnitsky won a bronze medal competing as part of a delegation of individual Russian athletes who have passed international doping tests.
The International Olympic Committee had allowed for 169 athletes to compete as "Olympic Athletes from Russia" after banning the Russian national team for state-sponsored doping.
Krushelnitsky said Tuesday he has never knowingly taken any banned substances and would welcome an investigation.
“I, more than anyone else, am interested in an investigation as soon as possible to find out the reasons for what has happened,” Krushelnitsky said in a statement published on the website of Russia’s curling federation.
“Not once in the whole time that I have been in sport have I taken any banned substance or competed dishonestly in any way,” he said, describing the test result as “a shock”.