I understand that かと思った is used to mean something along the lines of "I thought", however I am unsure as to what difference there is when の is added in のかと思った. What is the function (question marker, nominalisation?) of the の particle in the first place, and how does it affect the nuance overall?
1 Answer
Simply put, the の in that position is an explanatory-の. Can you explain the difference between "見ました" and "見たのです"? Or the difference between "食べる?" and "食べるの?" If yes, the difference between かと思った and のかと思った is the same; in the latter, the verb before の is working as a clarification of the topic or situation at hand. In English, you seldom need to express this nuance explicitly, but the closest equivalent would be the phrase "it's that ~". In Japanese, you need の very often to make natural sentences.
For example, let's compare 死ぬかと思った and 死ぬのかと思った. The former is a rather simple sentence meaning "I thought [I/you/he/she] almost died!", said after a narrow escape from death. On the other hand, the latter has an explanatory nuance around 死ぬ, so when translated verbosely, it's more like "I thought it meant [he/she] would die!". For example, you may say this when you noticed someone's death flag but that character didn't die.
I know this type of の is tricky to an English speaker, so please take your time to get accustomed to it. Also note that の has other usages.