I was a student in USA on visa, nonresident for tax purpose. I lived in 2 states during the year - lived for 3 months in one state and 9 months in the other. However, I earned wages only in the other state - I have W2 showing income only in that state. Do I have to file state tax returns in both states? Or should I file only state tax where I earned income? Any comments are appreciated. Thanks in advance!
You should only file in the State in which you earned income. As a student being in the US for a total of 9 months, you're likely not to be a tax resident of any State.
Keep in mind that if you earned wages in State A while living in State B, and didn't tell your employer about that - you'll need to file in both A and B and pay appropriate taxes. However if all your earnings are from work preformed in State A while physically present there, you only file a tax return there.
For US citizens/people who stay for longer periods, various issues of nexus/residency can come into play, but I don't think it is something relevant to your situation.