South Africa were immediately in control as Motjeka Madisha scored from the spot and Pieterse saved the first effort from the visitors.
Bafana Bafana have crashed out of the COSAFA Cup following a defeat to Madagascar on penalties after the two teams were deadlocked 0-0 at full-time.
South Africa were expected to win the match with ease against a team ranked 114th in the world but the lottery of a penalty shootout saw the home side shocked as Madagascar remained calm to record a 5-3 win.
South Africa will be kicking themselves after a number of excellent chances were not converted during regulation time.
The first chance of the match fell to Lebohang Maboe but he could only flash his shot wide of the post.
In the 20th minute, striker Luther Singh had an excellent chance to score but could not beat the keeper when he found himself one on one.
Reyaad Pieterse was called into action for the first time in the 34th minute when he brilliantly tipped a rasping shot from Jaotombo Bourah over the bar.
Maboe had another excellent opportunity to break the deadlock approaching half-time but could not get the better of the Madagascan shot-stopper as the teams went into the break at 0-0.
Pieterse was the first keeper called into action in the second half where he did well to prevent Bourah from scoring after he had managed to get behind the Bafana defenders.
In the 63rd minute, Aubrey Modiba almost broke the deadlock as his shot rattled the crossbar of the Madagascan goal.
It was all South Africa now as Ryan Moon headed wide from a free-kick in the 73rd minute.
But no breakthrough was forthcoming for either team and at 0-0 at full-time, the match went into a penalty shootout.
South Africa were immediately in control as Motjeka Madisha scored from the spot and Pieterse saved the first effort from the visitors.
The next two spot kicks from Foster and Modiba were converted by the hosts while Ando scored for the visitors to see South Africa lead the shootout 3-1.
And then disaster struck as both Webber and Singh missed with their attempts while Madagascar converted theirs to take a famous victory. — Sport 24