It is shown that there exists a 2-dimensional matrix representation of complex quaternions over real quaternions, which allows to define Pauli matrix in 4 dimensions over the quaternionic field and leads to the quaternionic spinor group previously proposed. It is also attempted to apply complex quaternions to general relativity at the level of the variational formalism. Linear gravitational Lagrangian in Riemann-Cartan space-time U4 is derived using quaternion caluculus; namely scalar curvature in U4 is put into a quaternionic form. Consequently, Einstein-Hilbert Lagrangian in Riemann space R4 is also defined over quaternions, as first shown by Sachs. The matter fields coupled to gravity are assumed to be the scalar and the Dirac fields. The quaternionic variational formalism corresponds to the first-order formalism but with a limited pattern of allowed fields such that the quaternionic fields carry only coordinate tensor indices but no local Lorentz indices which are contracted with that possessed by the basis of complex quaternions. In particular, both the quaternionic vierbein field and Lorentz gauge field (corresponding to the spin connection) are regarded as coordinate vectors which are independently varied, obtaining Einstein and Cartan equations, respectively. It is incidentally shown that the consistent condition of Einstein equation in U4 is proved via the variational formalism and the anti-symmetric part of Einstein equation together with Cartan equation in U4 leads to an identity which expresses the anti-symmetric part of the enegy-momentum tensor by means of the covariant divergence of the spin angular momentum tensor, both of Dirac field. We also present pedagogical proofs of Bianchi and Bach-Lanczos identities in U4 using the quaternionic formalism.