Coherent coupling of two qubits mediated by a nonlinear resonator is studied. It is shown that the amount of entanglement accessible in the evolution depends on both the strength of nonlinearity in the Hamiltonian of the resonator and on the initial preparation of the system. The created entanglement survives in the presence of decoherence.