The Angels were up 6-2 in the fourth inning and 6-4 when Ohtani left the game after the top of the sixth. But Baltimore scored a run in the seventh and five in the eighth. Ramon Urias and Kelvin Gutierrez drew bases-loaded walks to put the Orioles up 7-6, and pinch hitter Austin Hays added a two-run double.
The Orioles were two losses shy of the American League record for the longest skid -- which they set themselves in 1988 when they started 0-21.
"There was tension in our dugout, there was pressure. Everybody was on the top step," Orioles manager Brandon Hyde said. "Our guys just really wanted this one. We're tired of hearing, tired of seeing it on TV. Everybody's tired of it."
Ohtani allowed three homers on the mound and struck out three times at the plate, but the Orioles still seemed headed to a 20th straight loss after Brandon Marsh hit his first career homer, a three-run shot in the fourth that made it 6-2.
It was 6-5 when Jake Petricka (0-1) allowed a single, a double and an intentional walk to start the bottom of the eighth. He then walked Urias, his final batter, on four pitches to tie the game.
James Hoyt came on and struck out Jahmai Jones, but then he walked Gutierrez on a full count. Hays then doubled to left with the bases loaded, and Cedric Mullins added a sacrifice fly.
When Tyler Wells retired the final batter of the game on a flyout to right, he hugged catcher Pedro Severino and the Orioles celebrated casually on the field. The fans -- many of whom probably came to see Ohtani -- roared their approval.
Mullins and Anthony Santander hit solo homers in the first, and DJ Stewart hit a two-run shot off Ohtani in the fourth, as the Orioles finally had a chance to celebrate something in their clubhouse.
"It's electric in there," Mullins said of the home locker room.
Jared Walsh also homered for the Angels.
Tanner Scott (5-4) won in relief for the Orioles.
Ohtani allowed four runs and five hits in five innings. Chris Ellis, making his first career start, yielded three runs and five hits in three-plus innings after the Orioles claimed him off waivers from Tampa Bay on Friday.
"He's playing again [Thursday]," Angels manager Joe Maddon said of Ohtani. "And I didn't see any need to push him at this time of year under the circumstances."
Mullins' homer came on Ohtani's first pitch of the game, but after Santander's solo shot gave Baltimore a 2-0 lead, the Angels tied it almost immediately on a two-run single by Marsh in the second.
Walsh hit a solo homer for Los Angeles in the fourth, and Marsh added his three-run shot later in the inning.
Mullins brought home a run in the seventh with a groundout.
On Thursday, when the Orioles seek two wins a row, Keegan Akin (0-8) will be on the mound. Akin allowed four runs in three innings against Los Angeles on July 2. Jaime Barria (2-2) will counter for the Angels.
The Associated Press contributed to this report.
Orioles snap 19-game losing streak vs. Angels
Baltimore rides a five-run eighth inning to a 10-6 win over the Angels to end its losing streak.