The outbreak in Victoria's capital has seen hundreds of cases in the past two weeks - more than 95% of new Australian infections.
Until now, the two states had maintained open borders even when others had shut them.
The closure, beginning on Wednesday, will restrict travel to permit holders.
Victoria's Premier Daniel Andrews said it was a joint decision with Prime Minister Scott Morrison and NSW Premier Gladys Berejiklian.
"This is one of those precautionary measures - it is one of those things that I think will help us in broader terms contain the spread of the virus," Mr Andrews told reporters on Monday.