It's commonly said that Thomas Aquinas did not accept the doctrine of the immaculate conception of Mary. For example, Wikipedia says:
Saint Thomas Aquinas refused to concede the Immaculate Conception, on the ground that, unless the Blessed Virgin had at one time or other been one of the sinful, she could not justly be said to have been redeemed by Christ.
The article cites the Summa Theologica, III, Q27, A2, which argues that Mary was sanctified after animation, not before:
And thus, in whatever manner the Blessed Virgin would have been sanctified before animation, she could never have incurred the stain of original sin: and thus she would not have needed redemption and salvation which is by Christ, of whom it is written (Matthew 1:21): "He shall save His people from their sins." But this is unfitting, through implying that Christ is not the "Saviour of all men," as He is called (1 Timothy 4:10). It remains, therefore, that the Blessed Virgin was sanctified after animation.
But recently, @Geremia made me aware that there is good reason to believe that Aquinas actually did support the immaculate conception of Mary in other writings.
What is the basis for saying that Aquinas did, at some point in his life, believe in the immaculate conception?