Bashir was not arrested while attending an African Union summit in Johannesburg last year as the South African government claimed he had immunity as the head of a member state.
When an emergency order was obtained from the High Court during the summit ordering Bashir's arrest, government lawyers admitted he had flown out of the country just a few hours earlier.
The government subsequently filed a plea against the arrest order at the Supreme Court of Appeal (SCA).
"It was disgraceful conduct."
More From This Section
SCA ruled that the failure to arrest Bashir was unlawful and dismissed the government's appeal.
South Africa is a signatory of the Hague-based ICC, which wants Bashir arrested for alleged war crimes related to the conflict in the Darfur region of Sudan.
The South African Litigation Centre (SALC) hailed the court ruling, saying it meant Bashir must be arrested if he returned to South Africa.
"The government should seek to uphold the rule of law instead of shielding suspected war criminals and the Supreme Court of Appeal has made this clear today," SALC director Kaajal Ramjathan-Keogh said.
The Sudanese leader has evaded justice since his indictment in 2009 for alleged crimes in the Darfur conflict in which 300,000 people were killed and two million forced to flee their homes.
The South African government made no immediate announcement on whether it would appeal against today's ruling.