Maryland is entitled to tax any of your income that is sourced there (interest <generally> and dividend income are exceptions). Income that was not earned in MD is not taxable by MD. In your nonresident TT/MD return you will have the opportunity to allocate your income items between MD-income and Non-MD income.
VA & MD have a reciprocal agreement whereby they do not tax the wages of each other's residents. i.e. MD cannot tax any wages you may have earned while working in MD.