The 28-year-old former Manchester City defender joined the club, initially on loan, from Brentford in January 2014.
And he has been a regular in Derek McInnes's side over the past two-and-a-half seasons.
"I was always confident we could try and get there and get a deal done," McInnes told the Aberdeen website. "It is absolutely brilliant news."

Agnius Naumovas, who was from Lithuania but had been living in the city, was found on Margaret's Avenue at about 20:00 local time on Christmas Day.
He was taken to hospital, where his injuries were described as serious.
Mr Naumovas, who was 29, died on Thursday evening.
A post-mortem examination has been carried out by the Irish state pathologist.
A 41-year-old man was arrested in Waterford on Friday morning.
Defender Shay Logan has signed a new two-year deal with Aberdeen, keeping him at Pittodrie until 2018.
[NEXT_CONCEPT]
A man in his 40s has been arrested after a man found with head injuries in Waterford city centre on Christmas Day died in hospital.