Canadian criminal law allows for a common law defence of necessity. Necessitas non habet legem; "Necessity knows no law." This well-known maxim reflects the theoretical basis of the defence of necessity: that in dire circumstances of looming peril, the claims of positive law seems to weaken. This controversial common law or judge-made defence has only been firmly recognized in Canadian law since 1984. It is recognized in Canada as a defence for crimes committed in urgent situations of clear and imminent peril in which the accused has no safe avenue of escape or legal way out of the situation.
 There is an objective or reasonableness requirement that requires the accused to reasonably resist the pressures that led to the commission of the crime. Anyone is entitled, by virtue of s.8(3) of the Criminal Code, to rely upon any excuse or defense available to him at common law.
 The defence of necessity is an excuse for an illegal act, not a justification for committing the illegal act. The leading case for the defence is Perka v. The Queen  [1984] 2 S.C.R. 232 in which Dickson J. described the rationale for the  defence as a recognition that:
 a liberal and  humane criminal law cannot hold people to the strict obedience of laws  in emergency situations where normal human instincts, whether of self-preservation or  of altruism, overwhelmingly impel disobedience. However, it  must be "strictly controlled and scrupulously limited." and can only be  applied in the strictest of situations where true "involuntariness" is  found.
 Three elements are required for a successful defence (R v Latimer, 2001 SCC 1, 1 SCR 3, at para 28):
 1. The accused  must be in an urgent situation of  imminent peril or danger.
 2. The accused must have had no reasonable legal alternative to breaking the law
 3. The harm inflicted by the accused must be proportional to the harm avoided by the accused
 The peril or danger  must be more than just foreseeable or likely. It must be near and unavoidable.
 At a minimum the  situation must be so emergent and the peril must be so pressing that normal human instincts cry out for action and make a counsel of patience  unreasonable. With regard  to the second element, if there was a reasonable legal alternative to breaking the law, then there can be no finding of necessity. Regarding the third element requiring  proportionality, the harm avoided must be at least comparable to the  harm inflicted.
 The first two elements must be proven according to the modified objective standard, which takes into account the situation and characteristics of the particular accused person (see R. v. Latimer (2001) at §§ 32–34). The third requirement for the defence of necessity, proportionality, must be measured on an objective standard. The objective standard being what a reasonable person would do in the circumstances. The two harms, at minimum, must be of a comparable gravity. When evaluating the gravity of the act, a matter of community standards infused with constitutional considerations of the accused and the victim are considered.
 In R. v. Latimer (2001), the Supreme Court of Canada affirmed that to charge a jury with respect to the defence of necessity there must be an air of reality for all three aspects of necessity.  The court further affirmed that the defence of necessity is not available to a defendant  when (1) the killing occurred when there was no imminent danger to either  the defendant or the victim, (2) reasonable legal alternatives are  available besides killing, and (3) the harm inflicted is not in  proportion to the harm avoided.
 Perka v The Queen (1984) provides a summary on the nature, basis and limitations on the defence of necessity:
(1) the defence of necessity could be conceptualized as either a justification or an excuse;
(2) it should be recognized in Canada as an excuse, operating by virtue of s. 7(3) of the Criminal Code;
(3) necessity as an excuse implies no vindication of the deeds of the actor;
(4) the criterion is the moral involuntariness of the wrongful action;
(5) this involvement is measured on the basis of society's expectation of appropriate and normal resistance to pressure;
(6) negligence or involvement in criminal or immoral activity does not disentitle the actor to the excuse of necessity;
(7) actions or circumstances which indicate that the wrongful deed was not truly involuntary do disentitle;
(8) the existence of a reasonable legal alternative similarly disentitles; to be involuntary the act must be inevitable, unavoidable and afford no reasonable opportunity for an alternative course of action that does not involve a breach of the law;
(9) the defence only applies in circumstances of imminent risk where the action was taken to avoid a direct and immediate peril;
(10) where the accused places before the court sufficient evidence to raise the issue, the onus is on the Crown to meet it beyond a reasonable doubt.
 More recently, in R v Kerr, 2004 SCC 44, [2004] 2 SCR 371 the defence of necessity was made out and the accused acquitted, where an inmate stabbed to death a fellow inmate after being threatened with his life. The Supreme Court of Canada restore the acquittal from trial on the basis that the accused "had a reasonable belief that the circumstances afforded him no legal way out" and the lethal attack he sought to avoid outweighed his breach of s. 88(1) (at para 96). Justice Binnie dissented in this case as he disagreed with applying necessity as he decided the accused had a double intention of carrying the knife (at para 85) as a defence tool and as a more general and regular purpose of carrying a knife.
 In R. v Bridges (1989), 48 C.C.C. (3d) 535, 61 D.L.R. (4th) 12 (B.C.S.C), the defence of necessity was not made out to an accused charged with contempt of court for a violation of a court order against interfering with an abortion clinic. The defence is available when wrongful acts are committed under pressure in which no reasonable person could withstand. In these circumstances, reasonable person could withstand the pressure to defy the court order and thus, the accused's honest belief that abortion was immoral does not change this fact. This decision was upheld at the British Columbia Court of Appeal R. v Bridges (1990), 62 C.C.C. (3d) 455, 78 D.L.R. (4th) 529 (B.C.C.A)
 In R v Shewchuk (2014) SKPC 164, The defence of necessity was not made out to an accused charged with impaired driving. The defendant had become intoxicated while ice fishing in a rural area and was unable to reach help. The defendant drove to a hill parking on the centre of the road hoping he would be found by a passerby but was discovered by officers. The court ruled that the defence of necessity would not hold. Thought the threat of hypothermia was sufficient for the first aspect of necessity and that hypothermia was imminent enough for the second aspect to apply. However the requirement that the harm inflicted is not disproportional to the harm avoided. The threat the defendant posed by parking in the centre of a road at night unaware and without lights was found to outweigh the harm avoided.
 
In Perka v. The Queen, the Court explores the history of the necessity defence in order to determine whether it is an excuse or a justification. The legal underpinnings of each are distinct. The majority concludes that it should be recognized in Canada as an excuse, operating by virtue of s. 7(3) of the Criminal Code: the defence of necessity excuses the accused of blame rather than acts as a justification of their actions. In a concurring opinion, Wilson J. leaves open the door to future case law finding that in some cases the defence can act as justification suggesting that:   It may generally be said that an act is justified on grounds of necessity if the court can say that not only was the act a necessary one but it was rightful rather than wrongful. The Supreme Court previously discussed the defence of necessity in Morgentaler v. The Queen  [1976] 1 S.C.R. 616 where they left open the possibility of its existence but did not conclude either way on the question. The Court of Appeal of Ontario again considered the defence of necessity in R v. Morgantaler, Smoling, and Scott but in this case they concluded that the defence of necessity should not have been brought before the jury.  It was not until 1984 in the case of Perka v. The Queen that the Supreme Court acknowledged the defense of necessity in Canada.
 In Morgentaler v. The Queen  [1976] 1 S.C.R. 616 the SCC decided that the defense of necessity was not available on these facts.  They based this decision on the lack of urgent and real medical need.  Only in situations when compliance with the law was demonstrably impossible should necessity be available.