Sri Lanka were 60/3 at close after bowling out South Africa for 222, an innings which owed much to a sparkling 86 off 87 balls by Quinton de Kock.
Markram, who made 60, said the South Africans, chasing a win to square the two-match series, were disappointed with their total.
"Coming into this Test match, we really wanted to score big and for batters to get big hundreds," said Markram.
"We are a bit disappointed but I thought the Sri Lankans bowled well. There was a bit of lateral movement and a bit of swing. Today was really tough."
Vishwa Fernando and Kasun Rajitha both took three wickets as Sri Lanka followed up their dramatic one-wicket win in the first Test in Durban with a disciplined bowling performance.
Fernando said he was pleased that South Africa skipper Faf du Plessis had decided to bat.
"I had confidence that I could take two or three wickets with the new ball," he said.
Fernando took advantage of early swing to dismiss Dean Elgar and Hashim Amla with successive deliveries in the sixth over of the match, which was followed in the next over by the run-out of Temba Bavuma as three wickets fell with the total on 15.
"I was bowling outswingers and was going too wide, so I tried to use the crease and then get one in. He was looking for the outswinger but it cut back in," he said of his dismissal of the left-hander Elgar.
The next ball swung in sharply to bowl the right-handed Amla. South Africa never recovered fully despite three half-century stands.
Markram and De Kock put on 57 at almost a run a ball for the fifth wicket before Kasun Rajitha took three wickets in successive overs, starting by trapping Markram leg before wicket.
"I felt I needed to grind out quite hard for a long period of time. To get out was bitterly disappointing," Markram said.
First Published: February 22, 2019, 12:34 AM IST