The 30-year-old Victorian, who made a name for himself as a young star at Adelaide United, returns home after spending the past decade in Germany's top two divisions.
Leckie wore the Socceroos captain's armband and scored the opener in their 3-0 win over Kuwait in a FIFA World Cup qualifier this week, his 12th goal in 64 international appearances.
He becomes City's fourth current Socceroos player, alongside Jamie Maclaren, Curtis Good and Connor Metcalfe.
"As a Melbourne boy I have followed Melbourne City's growth closely in recent years," Leckie said.
"The club are building something special and I'm excited to be coming home to join the Premiers after such an unbelievable season of football.
"I've been talking with all the Melbourne City players in the Socceroos squad, and I can't wait to get started, to get to work and bring home some more silverware for the fans."
Leckie recently stated that Australia's relatively good record with COVID-19 would be a factor in the next move for his family.
He leaves Hertha BSC after making 12 of his 14 Bundesliga appearances this season as a substitute.
City football director Michael Petrillo hailed Leckie's signing as a big move for the club going forward.
"The personal attributes that make [Leckie] such a successful Socceroos leader, and his pace, strength and skill on the pitch, will make him a vital part of delivering the 'City Style' football we play," Petrillo said.
"Winning the premiership was an important moment, but we are always looking forward to our next challenge and to continuously improve.
"We have big ambitions and Mathew's addition to the squad is a key part of the next phase of our growth."
City play Melbourne Victory at AAMI Park on Sunday in a derby to be played behind closed doors because of Melbourne's current coronavirus lockdown.