'Stop + to infinitive' means to pause what you're doing in order to do something else. 'Stopped speaking' would mean he ceased the act of speaking, but the context suggests he interrupted his activity to speak to Mary. The correct pattern is 'stopped to speak'.