Following this military training, Barry was posted to Cape Town, South Africa in 1816. Through Lord Buchan, Barry had a letter of introduction to the Governor, Lieutenant General Lord Charles Henry Somerset. Following the successful, even spectacular, treatment of Lord Charles's sick daughter, Barry was welcomed into the family, maintained a close friendship with the Governor, and became his personal physician. In 1822 Somerset appointed Barry as Colonial Medical Inspector, an extraordinary jump in expectations from Barry's low military rank which brought with it great responsibility. Over ten years of work in the Cape, Barry effected significant changes, among them improvements to sanitation and water systems, improved conditions for enslaved people, prisoners and the mentally ill, and provision of a sanctuary for the leper population. Barry also performed one of the first known successful Caesarean sections in which both mother and child survived; the child was christened James Barry Munnik in Barry's honour, and the name was passed down through the family, leading to Barry's name being borne by a later Prime Minister of South Africa, J. B. M. Hertzog. Barry also gained enemies by criticising local officials and their handling of medical matters, but the advantage of a close relationship with the Governor meant that the repercussions of these outspoken views were usually smoothed over.