Bangladesh beat South Africa in a one-day international in South Africa for the first time on Friday and did it convincingly by taking the series-opener by 38 runs.

Bangladesh's batters set up the history-making victory with Shakib Al Hasan (77), Liton Das (50) and Yasir Ali (50) all hitting half-centuries in a strong total of 314-7.

It was Bangladesh's best total in South Africa and came after South Africa won the toss and put the visitors in to bat at SuperSport Park in Centurion.

Spinner Mehidy Hasan Miraz undid South Africa with 4-61 in nine overs as the Proteas were all out for 276 in 48.5 overs.

The result was obvious well before the final wicket of Keshav Maharaj.

Brian Lara: Disappointing to see young cricketers leaving Test cricket  

The key moment came in the 46th over when Miraz had David Miller stumped for 79 off 57 for his fourth wicket, getting rid of South Africa's last hope and putting Bangladesh on the brink of a first victory 20 years after first touring South Africa.

Miraz was backed up by pacers Taskin Ahmed (3-36) and Shoriful Islam (2-47), whose early strikes put South Africa in trouble at 36-3.

Bangladesh didn't let that early advantage slip, despite the efforts of Miller and Rassie van der Dussen, who made 86.

Bangladesh players celebrated gleefully at the end, as did their coach Russell Domingo, a South African and a former Proteas coach.