I'm currently in the same situation! Just bought an overweight pony who is out of shape. Definitely start with building up their endurance, but keeping everything consistent is key!
Endurance, start by walking a lot and for a long time to then progress when he is okay with walking for a long period of time to trot and then canter. Even two hours of walking is okay. Just let him tell you when he's tired, look out for how he breathes, if he's panting then give him a break of course but let him tell you when to move on to more intense work.
Stamina is what will make him fit again without risking him to be overworked.