It will be 29-year-old Lyon's first experience of county cricket, having taken 247 wickets in 67 Tests.
"We've replaced a top international with another top international," Worcestershire director of cricket Steve Rhodes said.
Lyon's arrival is subject to clearance from Cricket Australia.
"Signing a top-class international spinner is terrific for us from the performance angle," Rhodes added.
"Nathan is also a very committed dressing room man and our young spinners like George Rhodes and Ben Twohig will have the opportunities to pick his brains over that period."
Pace bowler Hastings was named in Australia's 15-man squad for the Champions Trophy last month alongside fellow seamers Mitchell Starc, Josh Hazlewood, Pat Cummins and James Pattinson, who is currently playing for Nottinghamshire.
The tournament starts on 1 June with Australia's first match the following day against New Zealand at Edgbaston.
Worcestershire have signed Australia off-spinner Nathan Lyon to replace compatriot John Hastings during the Champions Trophy in June.