Unlikely to be the motor. Sounds like a dying battery. That would charge to full voltage, but sag seriously as soon as power was drawn, and then cut out when the sag was too great. Even if you could check the voltage it would probably appear OK, unless you could check it while riding.
That...