Using A Multi-Phase Transport (AMPT) model, we study J/psi production from interactions between charm and anti-charm quarks in initial parton phase and between D and Dbar mesons in final hadron phase of relativistic heavy ion collisions at the Relativistic Heavy Ion Collider (RHIC). Including also the inverse reactions of J/psi absorption by gluons and light mesons, we find that the net number of J/psi from the parton and hadron phases is smaller than that expected from the superposition of initial nucleon-nucleon collisions, contrary to the J/psi enhancement predicted by the kinetic formation model. The production of J/psi is further suppressed if one includes the color screening effect in the parton phase. We have also studied the dependence of J/psi production on the charm quark mass and the effective charm meson mass.