POTCHEFSTROOM, South Africa (AP) — Dean Elgar fell one run short of a double-century as South Africa declared on 496-3 and led Bangladesh by 369 runs at stumps on Day 2 of the first test on Friday.

Elgar holed out to midwicket on 199 with an attempted hook shot, denying him the milestone, but it didn't affect South Africa's strong position at Senwes Park in Potchefstroom.

Bangladesh was 127-3 in its first innings. Captain Mushfiqur Rahim (44) was the vital wicket for South Africa in the final session, dropped twice by Elgar before Aiden Markram held a catch at short leg off spinner Keshav Maharaj.

Both those drops came off Maharaj before he finally got Mushfiqur.

South Africa had made early breakthroughs to get both Bangladesh openers out, and Mominul Haque (28 not out) and Tamim Iqbal (22 not out) took Bangladesh to the close. Tamim, showing a steely nerve, skipped down the track and hit the last ball of the day from Maharaj over long-on for a big six.

The attacking 67-run partnership between Mushfiqur and Mominul gave Bangladesh some hope that it can get close to South Africa's score on a batting-friendly surface.

Elgar's career-best score was the anchor for South Africa to pile on the runs after being given the opportunity to bat first on the placid pitch.

Bangladesh was regretting that decision to bowl first as Elgar made a big century, Hashim Amla added 137, and opener Markram made 97 on debut on the first day. Elgar and Amla put on 215 for the second wicket, following on from the 196-run opening stand by Elgar and Markram.

Captain Faf du Plessis was 26 not out and Temba Bavuma 31 not out when South Africa decided at the tea break that they had enough runs to put Bangladesh in. Du Plessis and Bavuma's unbroken partnership was worth 51.

Bangladesh did manage two wickets in the day's second session, their first success since Markram was run out just before tea on the first day.

Shafiul Islam had 1-74 and Mustafizur Rahman 1-98 for Bangladesh.

Amla fell straight after lunch, caught at backward point. His 27th test century took him past West Indies' Garry Sobers on the all-time list and level with Graeme Smith for the second-most hundreds by a South African. Jacques Kallis, the leading South African, has 45 test centuries.

Elgar hit 15 fours and three sixes and is the top run-scorer in test cricket this year following his ninth career ton and fourth of 2017.

He fell agonizingly short of 200, though, trying to play a hook off Rahman and lobbing a catch to Mominul at midwicket.

South Africa and Bangladesh will play two tests, with the series Ottis Gibson's first in charge of South Africa.