I've often read that St. Thomas denied the Immaculate Conception. I will try to make a brief argument that he never did.
Original sin is the disturbed relationship with God that has been passed on since the primal sin of Adam from generation to generation. Already in the the first centuries of Christianity the conviction grew that this chain must have been broken in Mary, should she be a fitting mother of God who became man. In St. Thomas' time, theologians disputed the moment when this chain was broken in Mary: was it from the moment of her (bodily) conception, or from the moment of her animation (creation and infusion of the rational soul)?
St. Thomas held the latter view, but for a good reason; according to medieval biology the moment of conception preceded the moment of animation. We now believe that they coincide. With that in mind, St. Thomas' statements in his Summa (Part 3, Question 14, Article 3), that "the flesh of the Virgin was conceived in original sin", and in his Commentary on the Angelic Salutation (Full of Grace), that "the Blessed Virgin was conceived in original sin, but was not born in it", cannot be read as a rejection of the Immaculate Conception. When St. Thomas talks about the conception of the Blessed Virgin, he is referring only to her body and not her soul. It would not have made any sense for him to say, that the body of the Blessed Virgin was immaculately conceived, because sin and sanctification presuppose a rational soul as carrier.
That the Blessed Virgin was never touched by sin, St. Thomas makes even more clear in his Commentary on the Sentences (Super Sent., lib. 1 d. 44 q. 1 a. 3 ad 3), where he says, "such was the purity of the Blessed Virgin, who was immune from original and actual sin". This view was confirmed by Pius IX in the bull Ineffabilis Deus, which defined the dogma of Mary's Immaculate Conception.