It is quite possible that Mr Johnson loses his seat in the upcoming general election, while the Conservative party gains a majority.
Does the Conservative party have official procedures for what would happen?
He would have two options if this was the case. One is he could step down and the conservative party could appoint a replacement. Second is he could technically continue in the post if he was appointed a lord.
If Mr Johnson does lose his seat, he could technically continue as Prime Minister so long as the Conservative Party win a majority. But he would have to appoint himself a Lord.
In this unlikely event, he would face an enormous amount of pressure to resign and would probably be replaced by another Tory MP in a leadership election.