In situ immobilization of enzyme into metal–organic frameworks (MOFs) is performed through a one-step and facile method. Candida antarctica lipase B (CalB) is directly embedded in zeolitic imidazolate framework (ZIF)-8 by simply mixing an aqueous solution of 2-methylimidazole and zinc nitrate hexahydrate [Zn(NO3)2⋅6H2O] containing CalB at room temperature. Due to the intrinsic micropores of ZIF-8, the obtained CalB@ZIF composite is successfully applied in size-selective transesterification reaction in organic solvent. CalB@ZIF not only shows much higher catalytic activity but also exhibits higher thermal stability than free CalB. Besides, the robust ZIF-8 shell also offers the hybrid composites excellent reusability.