This is a complicated situation, especially considering there are current orders and you went back to Maryland to attend court. You need to contact a family law attorney in your area to discuss this issue. You have established the 6 month residency requirement for what is referred to as "home state" jurisdiction, but there are more factors for a court to consider. Both courts will likely have to talk about the circumstances, and Maryland may not want to relinquish jurisdiction, which is why you need tot alk to an attorney.
NOTE: This answer is made available by the lawyer for educational purposes only. By using or participating in this site you understand that there is no attorney client privilege between you and the attorney responding. This site should not be used as a substitute for competent legal advice from a licensed professional attorney that practices in the subject practice discipline and with whom you have an attorney client relationship along with all the privileges that relationship provides. The law changes frequently and varies from jurisdiction to jurisdiction. The information and materials provided are general in nature, and may not apply to a specific factual or legal circumstance described in the question.
Sign up to receive a 5-part series of useful information and advice about child custody law.