© 2016 American Physical Society. We measure the time-dependent CP asymmetry in the radiative-penguin decay B0→KS0π-π+γ, using a sample of 471×106 (4S)→BB-events recorded with the BABAR detector at the PEP-II e+e- storage ring at SLAC. Using events with mKππ<1.8 GeV/c2, we measure the branching fractions of B+→K+π-π+γ and B0→K0π-π+γ, the branching fractions of the kaonic resonances decaying to K+π-π+, as well as the overall branching fractions of the B+→ρ0K+γ, B+→K∗0π+γ and S-wave B+→(Kπ)0∗0π+γ components. For events from the ρ mass band, we measure the CP-violating parameters SKS0π+π-γ=0.14±0.25±0.03 and CKS0π+π-γ=-0.39±0.20-0.02+0.03, where the first uncertainties are statistical and the second are systematic. We extract from this measurement the time-dependent CP asymmetry related to the CP eigenstate ρ0KS0 and obtain SKS0ργ=-0.18±0.32-0.05+0.06, which provides information on the photon polarization in the underlying b→sγ transition.