While praying, I was in my second Ruku and leaned forward to rise, but then recalled I needed to perform Tashahud, so I went back down to do it before continuing my prayer. Is my prayer still considered valid?
Yes, your prayer is valid but you need to perform two Sajda of Sahw immediately after your prayer. Sajda of Sahw is prostration and saying : BISMILLAH WA BILLAH ALLAHUMMA SALLI Ala Mohammad Wa AALI Mohammed. Then sitting and prostrating again and repeating the same. Then saying Tashahhud and Salam.
Wassalam.