The former Millwall player has scored two international goals, having previously played for Northern Ireland at Under-21, U19 and U17 level.
His final season with Rotherham was marred by injury.
“I’m delighted to be coming home and once I had spoken with Tiernan and heard his plans for the club, it was a simple decision,” Ferguson told the Derry City FC website.
“I’ve been training hard after a frustrating last season and I’m feeling very strong. I will really benefit now from a full pre-season and be ready to go when the new campaign starts.
“Derry City is obviously a club I know a bit about and I’m well aware of how passionate that support base is. I’m really looking forward to doing my bit to hopefully bring success to the Brandywell.”