Exposure to underwater sound can cause permanent hearing loss and other physiological effects in marine animals. To reduce this risk, naval sonars are sometimes gradually increased in intensity at the start of transmission ('ramp-up'). Here, we conducted experiments in which tagged humpback whales were approached with a ship to test whether a sonar operation preceded by ramp-up reduced three risk indicators - maximum sound pressure level (SPLmax), cumulative sound exposure level (SELcum) and minimum source-whale range (Rmin) - compared with a sonar operation not preceded by ramp-up. Whales were subject to one no-sonar control session and either two successive ramp-up sessions (RampUp1, RampUp2) or a ramp-up session (RampUp1) and a full-power session (FullPower). Full-power sessions were conducted only twice; for other whales we used acoustic modelling that assumed transmission of the full-power sequence during their no-sonar control. Averaged over all whales, risk indicators in RampUp1 (n=11) differed significantly from those in FullPower (n=12) by -3.0?dB (SPLmax), -2.0?dB (SELcum) and +168?m (Rmin), but not significantly from those in RampUp2 (n=9). Only five whales in RampUp1, four whales in RampUp2 and none in FullPower or control sessions avoided the sound source. For RampUp1, we found statistically significant differences in risk indicators between whales that avoided the sonar and whales that did not: -4.7?dB (SPLmax), -3.4?dB (SELcum) and +291?m (Rmin). In contrast, for RampUp2, these differences were smaller and not significant. This study suggests that sonar ramp-up has a positive but limited mitigative effect for humpback whales overall, but that ramp-up can reduce the risk of harm more effectively in situations when animals are more responsive and likely to avoid the sonar, e.g. owing to novelty of the stimulus, when they are in the path of an approaching sonar ship.