Then, as I continued gazing at her, something came to my mind. They were the remnants of the dream I had before waking up.
Is that grammatically correct? If not, what's the closest alternative?
No, it's not correct. If OP wants to use singular something in the first sentence, this must be referenced by a singular form in the second.
Here are a number of written instances of it is the remnants, which I think show that in the right context there's nothing inherently wrong with treating the remnants as a singular noun.
But in OP's context this is unnecessary, To avoid potential accusations of "clumsiness", I would either adopt Kris's suggestion (just drop they were completely), or change singular something to a more suitable plural (such as some thoughts or ideas).
"Then, as I continued gazing at her, the remnants of the dream I had before waking up came to my mind."
It seems odd to me to use the abstraction "something" and then immediately explain clearly what the something was/is. But that is a stylistic point, really. However, avoiding the use of "something" removes the problem of agreement in number with "remnants".