The 25-year-old moved to Ashton Gate in November and made eight appearances for the Robins before landing a permanent contract.
"I'm excited about the future ahead. I'm delighted to have signed the deal," the former Brentford centre-back told Bristol City's official website.
"I've thoroughly enjoyed my time at the club so far and hopefully we can start moving up the table in the near future."
City boss Steve Cotterill said: "Karleigh will only get better. I'm delighted he has decided that he'd like his future to be at Bristol City."