The Orioles took an 8-0 lead in the fifth. Markakis robbed Allen Craig with a catch in the gap for the second out in the bottom of the inning.
"Of course it still crosses your mind, a perfect game is still very difficult to do, so I tried to concentrate on each at-bat," Chen said through a translator.
Dan Butler then doubled off the Green Monster with one out in the sixth, ending the pitching drama.
"Wei-Yin was tough," Orioles manager Buck Showalter said. "I love the way he attacked with the lead, pitched real well with the lead. A lot of people nitpick around. He had some depth on his off-speed stuff again."
Chen (15-4) gave up one run and three hits in seven innings, striking out four without a walk. The left-hander felt throwing strikes early in counts was important.
"I was able to get ahead of the hitters and they were more aggressive than they should be, that's why I was so efficient," he said.
The Red Sox scored five runs in the ninth, but it wasn't nearly enough after Chen shut them down.
"Stayed out of the middle of the plate. He's been a guy that notoriously is effective against us," Boston manager John Farrell said. "He pitches right-handers in. He's got multiple secondary pitches that he can go to, but I think more than anything it's the consistent location that he shows."
Darren O'Day got the last out with two runners on for his third save.
Brandon Workman (1-9) lost his ninth straight decision since winning at Baltimore on June 10.
Jones' two-run double highlighted a six-run third, and Joseph hit a two-run drive in the fifth. Jones and Joseph each had three hits.
Chen improved to 12-2 in his last 21 starts. The only run off the left-hander scored on a home run by Xander Bogaerts.
The Orioles combined six hits -- two by Flaherty -- two walks and Rivero's throwing error from third base for their burst in the third. Alejandro De Aza, Joseph and Flaherty each had RBI singles and Steve Pearce drew a bases-loaded walk.
NOT SO FAST
With their magic number in single digits for clinching the AL East and a 10-game homestand coming up, the Orioles can possibly clinch at home. Showalter wasn't about to think that far ahead. "If that comes to be the potential for that to happen, that's so far away, if we're fortunate to have that day happen, then we can talk about it," he said. "We've got a lot of roads to cross."
A PAIR OF SINGLES IN THIRD
Flaherty became the third Orioles player to get two hits in an inning this season. Joseph did it Aug. 31 against Minnesota.
Orioles: SS J.J. Hardy missed his fifth straight game with lower back spasms. The hope is he'll be ready to play in Friday's doubleheader against the Yankees. "He's feeling good," Showalter said. "We'll have a better idea (Thursday)."
Red Sox: Farrell said after the game that 2B Dustin Pedroia is done for the season was scheduled to have surgery Thursday for soreness in his left wrist and hand. "He's going to have a procedure done here tomorrow by Dr. Leibman in Boston that will address what he's dealing with right now," Farrell said. "I don't know any more specifics than that, but there will be certainly a follow-up after that's completed tomorrow."... INF-OF Brock Holt missed his fifth straight because of illness, but is expected to play in the upcoming series in Kansas City.
Orioles: Off Thursday before opening a 10-game homestand with a doubleheader against the Yankees on Friday. RHP Kevin Gausman (7-7, 3.83 ERA) and RHP Bud Norris (12-8, 3.92) are slated to go for Baltimore.