The phase stability and electronic and mechanical properties of rare earth (RE) carbides (La2C3, LaC2, Ce2C3, CeC2, and CeC) were investigated using first-principles calculations based on density functional theory. The calculated equilibrium lattice constants and cell volume agree well with available experimental data. The cohesive energy and formation enthalpy of these carbides show that they are thermodynamically and mechanically stable except LaC. The strong covalent bonding exists in these compounds, and the covalent bonds are mainly determined to be RE–C and C–C bonds. The hardness of RExCy compounds is less than 10 GPa, and the bulk modulus, shear modulus, and Young’s modulus of Ce2C3 are the largest. The values of B/G (ratio of bulk modulus to shear modulus) and Poisson’s ratio indicate that all the compounds have good ductility, and the ductility of CeC is larger than others. The Debye temperature of Ce2C3 is 429.67 K, which is the highest in those of experimental compounds.