The prime minister, along with the other ministers in cabinet, is appointed by the governor general on behalf of the monarch.
However, by the conventions of responsible government, designed to maintain administrative stability, the governor general will call to form a government the individual most likely to receive the support, or confidence, of a majority of the directly elected members of the House of Commons; as a practical matter, this is often the leader of a party whose members form a majority, or a very large plurality, of Members of Parliament (MPs).

While there is no legal requirement for prime ministers to be MPs themselves, for practical and political reasons the prime minister is expected to win a seat very promptly.
However, in rare circumstances individuals who are not sitting members of the House of Commons have been appointed to the position of prime minister.
Two former prime ministers—Sir John Joseph Caldwell Abbott and Sir Mackenzie Bowell—served in the 1890s while members of the Senate.
Both, in their roles as Government Leader in the Senate, succeeded prime ministers who had died in office—John A. Macdonald in 1891 and John Sparrow David Thompson in 1894.
That convention has since evolved toward the appointment of an interim leader from the commons in such a scenario.

Prime ministers who are not MPs upon their appointment (or who lose their seats while in office) have since been expected to seek election to the House of Commons as soon as possible.
For example, William Lyon Mackenzie King, after losing his seat in the 1925 federal election (that his party won), briefly "governed from the hallway" before winning a by-election a few weeks later.
Similarly, John Turner replaced Pierre Trudeau as leader of the Liberal Party in 1984 and subsequently was appointed prime minister while not holding a seat in the House of Commons; Turner won a riding in the next election but the Liberal Party was swept from power.
Turner was the last prime minister to not occupy a House of Commons seat while in office as prime minister.

Should a serving prime minister today lose his or her seat in the legislature, or should a new prime minister be appointed without holding a seat, the typical process that follows is that a junior member in the governing political party will resign to allow the prime minister to run in the resulting by-election.
A safe seat is usually chosen; while the Liberal and Conservative parties traditionally observed a convention of not running a candidate against another party's new leader in the by-election, the New Democratic Party and smaller political parties typically do not follow the same convention.
However, if the governing party selects a new leader shortly before an election is due, and that new leader is not a member of the legislature, he or she will normally await the upcoming election before running for a seat in parliament.

In a poll conducted by Ipsos-Reid following the first prorogation of the 40th parliament on December 4, 2008, it was found that 51% of the sample group thought the prime minister was directly elected by Canadians.
The prime minister, along with the other ministers in cabinet, is appointed by the governor general on behalf of the monarch. However, by the conventions of responsible government, designed to maintain administrative stability, the governor general will call to form a government the individual most likely to receive the support, or confidence, of a majority of the directly elected members of the House of Commons; as a practical matter, this is often the leader of a party whose members form a majority, or a very large plurality, of Members of Parliament (MPs).
While there is no legal requirement for prime ministers to be MPs themselves, for practical and political reasons the prime minister is expected to win a seat very promptly. However, in rare circumstances individuals who are not sitting members of the House of Commons have been appointed to the position of prime minister. Two former prime ministers—Sir John Joseph Caldwell Abbott and Sir Mackenzie Bowell—served in the 1890s while members of the Senate. Both, in their roles as Government Leader in the Senate, succeeded prime ministers who had died in office—John A. Macdonald in 1891 and John Sparrow David Thompson in 1894. That convention has since evolved toward the appointment of an interim leader from the commons in such a scenario.
Prime ministers who are not MPs upon their appointment (or who lose their seats while in office) have since been expected to seek election to the House of Commons as soon as possible. For example, William Lyon Mackenzie King, after losing his seat in the 1925 federal election (that his party won), briefly "governed from the hallway" before winning a by-election a few weeks later. Similarly, John Turner replaced Pierre Trudeau as leader of the Liberal Party in 1984 and subsequently was appointed prime minister while not holding a seat in the House of Commons; Turner won a riding in the next election but the Liberal Party was swept from power. Turner was the last prime minister to not occupy a House of Commons seat while in office as prime minister.
Should a serving prime minister today lose his or her seat in the legislature, or should a new prime minister be appointed without holding a seat, the typical process that follows is that a junior member in the governing political party will resign to allow the prime minister to run in the resulting by-election. A safe seat is usually chosen; while the Liberal and Conservative parties traditionally observed a convention of not running a candidate against another party's new leader in the by-election, the New Democratic Party and smaller political parties typically do not follow the same convention. However, if the governing party selects a new leader shortly before an election is due, and that new leader is not a member of the legislature, he or she will normally await the upcoming election before running for a seat in parliament.
In a poll conducted by Ipsos-Reid following the first prorogation of the 40th parliament on December 4, 2008, it was found that 51% of the sample group thought the prime minister was directly elected by Canadians.
Prime Minister of Canada