An extension of the back-calculation method to reconstruct the past history of HIV infections is presented. In this method the HIV infection intensity, as a function of age and calendar time, is assumed to belong to a family of parametric functions and is back-calculated from the observed AIDS incidence cases, knowledge of the incubation period and of the susceptible population, the final model being chosen as the one that gives the best fit. The model allows for the interaction between age and calendar time. The application to the main risk groups in Italy, male IVDUs and homosexuals, showed that age and the susceptible population were important in estimating the epidemic among IVDUs; interaction between age and calendar time was found to be significant, showing that among young IVDUs the risk of infection decreased faster than among older IVDUs. Sensitivity of the estimates to the assumption of population and choice of the infection function is investigated.