The discovery of photonic topological insulators (PTIs) has opened the door to fundamentally new topological states of light.Current time-reversal-invariant PTIs emulate either the quantum spin Hall (QSH) effect or the quantum valley Hall (QVH) effect in condensed-matter systems, in order to achieve topological transport of photons whose propagation is predetermined by either 'photonic pseudospin' (abbreviated as 'spin') or valley. Here we demonstrate a new class of PTIs, whose topological phase is not determined solely by spin or valley, but is controlled by the competition between their induced gauge fields. Such a competition is enabled by tuning the strengths of spin-orbit coupling (SOC) and inversion-symmetry breaking in a single PTI. An unprecedented topological transition between QSH and QVH phases that is hard to achieve in condensed-matter systems is demonstrated. Our study merges the emerging fields of spintronics and valleytronics in the same photonic platform, and offers novel PTIs with reconfigurable topological phases.