Resource management for ad hoc grids is challenging due to the participation of heterogeneous, dynamic, autonomous and ephemeral nodes. Different underlying network infrastructures, and varying use and access policies make resource management even more complex. Therefore it is required to develop such a resource management mechanism that will enable the ad hoc grid to self-organize according to the workload of the resource manager. The proposed mechanism is based on the emergent behavior of the participating nodes and adapts with respect to changes in the ad hoc grid environment. Scalability and robustness of the proposed mechanism is tested by running the experiments on PlanetLab. Simulation results show that our mechanism performs better than previously proposed mechanisms.