A method for delivering a medicament to a mechanically ventilated patient (4) receiving a flow of breathing gas comprises delivering a respiratory maneuver to such a patient (4), monitoring the physiological effects of the respiratory maneuver on such patient (4), automatically establishing an optimized respiratory maneuver in response to the monitored physiological effects, and delivering the optimized respiratory maneuver to such a patient (4). A system for delivering an aerosolized medicament to a ventilated patient (4) is also provided.