In this paper, we present a theoretical model based on the detailed balance theory of solar thermophotovoltaic systems comprising multijunction photovoltaic cells, a sunlight concentrator and spectrally selective surfaces. The full system has been defined by means of 2n + 8 variables (being n the number of sub-cells of the multijunction cell). These variables are as follows: the sunlight concentration factor, the absorber cut-off energy, the emitter-to-absorber area ratio, the emitter cut-off energy, the band-gap energy(ies) and voltage(s) of the sub-cells, the reflectivity of the cells' back-side reflector, the emitter-to-cell and cell-to-cell view factors and the emitter-to-cell area ratio. We have used this model for carrying out a multi-variable system optimization by means of a multidimensional direct-search algorithm. This analysis allows to find the set of system variables whose combined effects results in the maximum overall system efficiency. From this analysis, we have seen that multijunction cells are excellent candidates to enhance the system efficiency and the electrical power density. Particularly, multijunction cells report great benefits for systems with a notable presence of optical losses, which are unavoidable in practical systems. Also, we have seen that the use of spectrally selective absorbers, rather than blackbody absorbers, allows to achieve higher system efficiencies for both lower concentration and lower emitter-to-absorber area ratio. Finally, we have seen that sun-to-electricity conversion efficiencies above 30% and electrical power densities above 50W/cm are achievable for this kind of systems.