The new leader will replace Trudeau as PM; he said he'd step down as PM once the leader is elected. It's just that the same day this happens, parliament will come back in session and almost certainly bring this new government down in a vote of non-confidence. The new leader will stay PM over the course of the campaign period.
Edit: The new government being voted down isn't as much of a certainty. The NDP have walked back their promise to do so; not sure about the Bloc. Either one could prop up the Liberals.
...and if Carney wins, he'll be PM but not an MP. The last time the PM was not a MP, it was John Turner. That was after Justin's father Pierre resigned. History is repeating.
The LPC lost badly under Turner in the next election - Cross your fingers.