Sharing the new ball with Kyle Abbott, the 20-year-old right-arm paceman conceded two runs in his first over before returning to wreak havoc.
He uprooted opener Tamim Iqbal's off-stump with the fourth delivery of the over before getting Litton Das caught at midwicket and trapping Mahmudullah lbw to achieve the feat.
Bangladesh left-arm spinner Taijul Islam became the first cricketer to claim a hat-trick on his ODI debut at the same Shere Bangla National Stadium late last year.
Bangladesh won the toss and decided to bat first against South Africa after a rain-delay had reduced it to a 40-overs-a-side contest.
Image: Kagiso Rabada of South Afric celebrates with team mates after taking a wicket
Photograph: Matt King/Getty Images
Leie shines on debut, South Africa clinch T20 series in Dhaka
Du Plessis leads South Africa to victory in Bangladesh
BRICS bank to start lending in local currency by April: Kamath
Mustafizur's six-for helps Bangladesh crush India again
De Villiers gets paternity leave, while four uncapped players called-up