The present invention provides pyrrolo[2,3-b]pyridine-4-yl amines pyrrolo[2,3-b]pyrimidin-4-yl amines that modulate the activity of Janus kinases and are useful in the treatment of diseases related to activity of Janus kinases including, for example, immune-related diseases and cancer.