Maryland awarded delegates based on the statewide vote, as well as results in individual congressional districts. GOP delegates in Virginia and the District of Columbia were winner take all.
A total of 113 Republican delegates were at stake Tuesday.
In the overall race for the nomination, McCain had 821 delegates and Huckabee had 241. It will take 1,191 delegates to secure the Republican nomination.
McCain spoke before supporters Tuesday in Alexandria, Va.
"We know where either of their candidates will lead this country, and we dare not let them," McCain said of the Democrats. "They will paint a picture of the world in which America's mistakes are a greater threat to our security than the malevolent intentions of an enemy that despises us and our ideals."
Sixty-five percent of voters in Virginia's Republican primary called themselves conservatives. Mike Huckabee won half of their votes, including two-thirds of those who called themselves "very conservative." In Maryland, conservatives were a similar share of the voters but McCain actually did better than Huckabee among them. Ron Paul and Mitt Romney, who has suspended his campaign, each got about one in 10 conservatives in Maryland.
Republicans John McCain and Mike Huckabee had struggled over 116 delegates in the GOP primaries in the so-called Potomac Primary contests.
McCain won the votes of 70 percent of moderates in Virginia, almost eight in 10 in Maryland. McCain won about half of those who called themselves "somewhat conservative" in both states.
Forty-nine percent of Republican voters in Virginia said McCain's policies were not conservative enough, slightly fewer said that in Maryland.
The surveys were conducted by Edison Media Research and Mitofsky International for The Associated Press and the television networks. There was no survey conducted in the District of Columbia.
It takes 1,191 delegates to clinch the Republican nomination, and McCain appears to be on track to reach the target by late April.
An Associated Press-Ipsos poll found Obama with a narrow lead over the Arizona senator in a potential match-up, and Clinton running about even.
A note on calculating delegates:
The AP tracks the delegate races by projecting the number of national convention delegates won by candidates in each presidential primary or caucus, based on state and national party rules, and by interviewing unpledged delegates to obtain their preferences.
In some states, like Iowa and Nevada, local precinct caucuses are the first stage in the allocation process. The AP uses preferences expressed in those caucuses to project the number of national convention delegates each candidate will have when they are chosen at county, congressional district or state conventions.