Aims. We present MUFFIT, a new generic code optimized to retrieve the main stellar population parameters of galaxies in photometric multi-filter surveys, and check its reliability and feasibility with real galaxy data from the ALHAMBRA survey. Methods. Making use of an error-weighted χ 2 -test, we compare the multi-filter fluxes of galaxies with the synthetic photometry of mixtures of two single stellar populations at different redshifts and extinctions, to provide the most likely range of stellar population parameters (mainly ages and metallicities), extinctions, redshifts, and stellar masses. To improve the diagnostic reliability, MUFFIT identifies and removes from the analysis those bands that are significantly affected by emission lines. The final parameters and their uncertainties are derived by a Monte Carlo method, using the individual photometric uncertainties in each band. Finally, we discuss the accuracies, degeneracies, and reliability of MUFFIT using both simulated and real galaxies from ALHAMBRA, comparing with results from the literature. Results. MUFFIT is a precise and reliable code to derive stellar population parameters of galaxies in ALHAMBRA. Using the results from photometric-redshift codes as input, MUFFIT improves the photometric-redshift accuracy by ∼10-20%. MUFFIT also detects nebular emissions in galaxies, providing physical information about their strengths. The stellar masses derived from MUFFIT show excellent agreement with the COSMOS and SDSS values. In addition, the retrieved age-metallicity locus for a sample of z ≤ 0.22 early-type galaxies in ALHAMBRA at different stellar mass bins are in very good agreement with the ones from SDSS spectroscopic diagnostics. Moreover, a one-to-one comparison between the redshifts, ages, metallicities, and stellar masses derived spectroscopically for SDSS and by MUFFIT for ALHAMBRA reveals good qualitative agreements in all the parameters, hence reinforcing the strengths of multi-filter galaxy data and optimized analysis techniques, like MUFFIT, to conduct reliable stellar population studies.