The problem of finding a nearly optimal distribution of polynomial degrees on a fixed finite element mesh is discussed. An a posteriori error estimator based-on the minimum complementary energy principle is proposed which utilizes the displacement vector held computed from the finite element solution. This estimator, designed for p- and hp-extensions, is conceptually different from estimators based on residuals or patch recovery which are designed for h-extension procedures, The quality of the error estimator is demonstrated by examples. The results show that the effectivity index is reasonably close to unity and the sequences of p-distributions obtained with the error indicators closely follow the optimal trajectory. (C) 1998 John Wiley & Sons, Ltd.