Over two miles of new track will be laid, and drainage systems improved, at locations along the line between Auchinleck and Dumfries during the project.
Two railway bridges on the line will undergoing refurbishment and strengthening works, with platform maintenance also taking place.
Due to the complexity of the engineering work and the heavy machinery involved, these upgrades cannot be delivered without the short-term closure of the line.
Buses will replace trains between Kilmarnock and Carlisle on Saturday, July 13, and Sunday, July 14, and then between Kilmarnock and Dumfries from Monday, July 15, until Thursday, July 25.
Lindsay Saddler, head of maintenance for Network Rail Scotland, said: “These upgrades are essential to maintaining a reliable service on the line, but they cannot be delivered without a short closure of the railway.
“Our engineers will be working around-the-clock to complete this complex programme as quickly as we possibly can as we understand the inconvenience these works will cause to some of our customers.”