Immune-checkpoint inhibitors (ICI) have revolutionized the therapeutic landscape of cancer. However, optimal patient selection is still an unmet need. One-hundred-forty-six patients with metastatic cancer candidates to ICI at the Hospital Clinic of Barcelona Clinical Trials Unit were prospectively recruited in this observational study. Blood samples were collected at different timepoints, baseline LIPI score calculated and pre-ICI archived tissues retrieved to evaluate PD-L1, tumor-infiltrating lymphocytes (TILs) and PD1 mRNA levels. Tumor assessments were centrally reviewed by RECIST 1.1 criteria. Associations with overall response rates (ORR), durable clinical benefit (DCB), progression-free survival (PFS) and overall survival (OS) were performed with univariable/multivariable logistic and Cox regressions, where appropriate. At a median follow-up of 26.9 months, median PFS and OS were 2.7 and 12.9 months. Response rates were 17.8% with duration of response (DOR) of 4.4 months. LIPI score was independently associated with PFS (p= 0.025) and OS (p< 0.001). Immunotherapy-naïve status was independently associated with better PFS (p= 0.005). Time-to-best response (TTBR) and ORR (p< 0.001 both) were associated with better OS at univariate analysis. PFS and DOR were moderately correlated with OS (p< 0.001 both). A PD-L1 10% cut-off detected worse/best responders in terms of ORR (univariate p = 0.011, multivariatep= 0.028) and DCB (univariatep= 0.043). PD1 mRNA levels were strikingly associated to complete responses (p= 0.021). To resume, in our prospective observational pan-cancer study, baseline LIPI score, immunotherapy-naïve status, cancer type and RT before starting ICI were the most relevant clinical factors independently correlated with immunotherapy outcomes. Longer TTBR seemed to associate with better survival, while PD1 mRNA and PD-L1 protein levels might be tumor-agnostic predictive factors of response to ICI and should be furtherly explored.Supplementary InformationThe online version contains supplementary material available at 10.1007/s00262-022-03360-9.