On 10 January 2017, Badstuber joined Schalke 04 on loan until the end of the 2016–17 Bundesliga season. On the same day, it was confirmed by FC Bayern that Badstuber had signed a contract extension with the club lasting until 2018. In the first half of the season, Badstuber had made only one Bundesliga appearance, one DFB-Pokal appearance, and one Champions League appearance for Bayern.
Badstuber made his debut for the Königsblauen on 4 February 2017 against his parent club, playing 59 minutes as Bayern were held to a 1–1 draw in Munich. On 1 March 2017, Badstuber was sent off for two yellow card offences on his second return to the Allianz Arena as Schalke lost 3–0 to Bayern in the quarter-final of the DFB-Pokal.
On 4 August 2017, a few weeks after being released by Bayern Munich, Badstuber announced his return to VfB Stuttgart, the club for whom he played as a young teenager, on a free transfer. He finished the 2017–18 season with two goals in 28 appearances.