Green hydrogen production using solar-powered Proton Exchange Membrane (PEM) electrolysis is limited by temperature fluctuations caused by variable solar irradiance. This study develops and dynamically simulates a novel thermally flexible system integrating a photovoltaic–thermal (PVT) collector, a PEM electrolyzer (PEME), and a phase change material (PCM)-based heat exchanger. The transient model, coded in Python, captures the coupled electrochemical, thermal, and mass-transport processes under the climatic conditions of Tehran, Iran. Validation against experimental and numerical data confirmed its reliability. Results indicate that incorporating the PCM unit substantially improves the thermal stability of the PEME by preheating the inlet water above 70 °C during early operation and maintaining a nearly constant stack temperature during peak solar hours. Consequently, the energy and exergy efficiencies of the integrated system increase by 2.5–3.5 percentage points compared to the configuration without PCM, with corresponding gains in hydrogen yield and thermal flexibility. The proposed integration of PVT, PEME, and PCM technologies effectively mitigates thermal stress and enhances electrolyzer durability, efficiency, and operational stability. These findings demonstrate a promising pathway toward reliable and high-efficiency solar hydrogen production in regions with fluctuating solar irradiance.