Hammel (7-2) controlled the Nationals on two runs, yielding eight hits without a walk while striking eight en route to his second win in two starts.
Trailing 1-0 in the fourth inning, the Orioles erupted for three runs to grab control, capped when Markakis sent home Matt Wieters and Yamaico Navarro with the go-ahead runs on a two-out base hit.
Navarro provided a pair of run-scoring singles for Baltimore, which took the opener of a three-game rivalry series.
Washington starter Gio Gonzalez (3-3) was touched for four runs on eight hits over 5 2/3 innings.
Ryan Zimmerman and Tyler Moore each drove in a run for the Nats.