Compounds represented by general formula (I) (all of the symbols in the formula conform to the definitions in the Description) are compounds that, in addition to having a Btk-selective inhibitory activity, exhibit an excellent metabolic stability and can avoid hepatotoxicity or the like, and as a consequence can provide safe therapeutic agents for diseases in which B cells or mast cells participate.