We examined whether a selective cyclooxygenase-2 (COX-2) inhibitor (celecoxib) was as effective as a non-selective inhibitor (ibuprofen) for the prevention of heterotopic ossification following total hip replacement. A total of 250 patients were randomised to receive celecoxib (200 mg b/d) or ibuprofen (400 mg t.d.s) for ten days after surgery. Anteroposterior radiographs of the pelvis were examined for heterotopic ossification three months after surgery. Of the 250 patients, 240 were available for assessment. Heterotopic ossification was more common in the ibuprofen group (none 40.7% (50), Brooker class I 46.3% (57), classes II and III 13.0% (16)) than in the celecoxib group (none 59.0% (69), Brooker class I 35.9% (42), classes II and III 5.1% (6), p = 0.002). Celecoxib was more effective than ibuprofen in preventing heterotopic bone formation after total hip replacement.