Before the L train shutdown, M line riders will bear the brunt of subway suffering.

The MTA on Saturday will shutter the tail end of M train service in Brooklyn and Queens through August for the first phase of critical rehabilitation work to the line’s aging above ground track.

No trains will run at the seven stations between Myrtle Avenue and Middle Village-Metropolitan Avenue to allow for large swathes of the elevated line to be replaced. Some 60,000 weekday riders will be left without a subway — a necessary trade off to prepare the line for increased and more reliable service during the L train shutdown in 2019, according to the MTA.

“The MTA’s top priority always has been and will continue to be providing safe and reliable service to our customers and this work is absolutely critical to the long term viability of this growing corridor,” said New York City Transit acting president Darryl Irick, in a statement.

Through Sept. 1, the MTA will run free shuttle buses along three separate routes. Two routes will mimic the train line. One shuttle route will run from Myrtle Avenue to the Myrtle-Wyckoff Avenues station of the L train and a second will run from the Myrtle-Wyckoff Avenues station to Middle Village. A third route will essentially serve as an express to the Middle Village station, making limited stops along the way. Shuttle service will be available 24 hours a day.

During that work, M trains will be rerouted to the J and Z line on Broadway, between the Myrtle Avenue and Broadway Junction stations.

The second phase of the $163 million project will last eight months, from September through April 2018, but the work will be less impactful, requiring the closure of the two stations between Myrtle Avenue and Myrtle-Wyckoff Avenues stations. Shuttle buses will fill the gap in service.

“It’s very necessary because the Myrtle Viaduct is seriously deteriorated,” said MTA board member Andrew Albert, who participated in a walking tour of the track. “They’re doing patchwork stuff but it absolutely must be fixed...before 2019 because a lot of the folks who use the L will switch to the M."