A generalization of the age replacement policy is proposed and analysed. Under such a policy, if an operating system fails at age y less-than-or-equal-to t, it is either replaced by a new system (type II failure) with probability p(y), or it undergoes minimal repair (type I failure) with probability q(y) = 1 - p(y). Otherwise, a system is replaced when the first failure after t occurs or the total operating time reaches age T(0 less-than-or-equal-to t less-than-or-equal-to T), whichever occurs first. The cost of the i-th minimal repair of a system of age y depends on the random part C(y) and the deterministic part c(i)(y). The aim of the paper is to find the optimal (t*, T*) which minimizes the long-run expected cost per unit time of the policy. Various special cases are included and a numerical example is finally given.