Relying on a filthy slider, Moronta struck out five in two innings of lights-out relief work and the Giants beat the Padres 3-2 for their first victory this season.
"Man, what a game-saving effort," manager Bruce Bochy said. "I mean, I put him in a tough situation there, man on second, nobody out, with who he had to face. His two great innings won the game for us."
San Francisco took a 3-0 lead in the sixth, highlighted by Yangervis Solarte's double. Giants starter Dereck Rodriguez (1-0) faltered in the bottom of the inning, allowing hits to the first two batters before Travis Bergen came on and allowed Eric Hosmer's two-run double.
Bochy then summoned Moronta, who struck out Machado, Wil Myers and Hunter Renfroe. Moronta, a 5-foot-8, 257-pound righty, struck out two more in the seventh, including prized rookie Tatis, to strand Greg Garcia after a pinch-hit double in his Padres debut.
Moronta had a habit last year of walking his first batter. But he struck out Machado on five pitches, including four sliders.
"I don't think about the batter," Moronta said through a translator. "My main concern is just go out there, do my job, concentrating on throwing strikes and really not worry about the situation of the game."
After Moronta struck out Machado, San Diego's $300 million slugger, the Padres complained about his light gray glove, and he was forced to switch to another one.
"That really doesn't bother me. They can complain about the color of my glove. It's not going to faze me a bit," he said. "I'm just out there trying to do my job."
Asked if he'd be available for Sunday's series finale, he said: "I'm always ready. This year I came ready to pitch whenever they need me. It doesn't matter the situation."
The Giants were at risk of going 0-3 for the first time since 2012, when they won their second of three World Series in five seasons under Bochy, who is retiring after this season.
The Padres were denied their first 3-0 start since 1984, the season they went to their first World Series, with Bochy as a backup catcher.
Rodriguez allowed two runs and four hits in five-plus innings, struck out two and walked none. Will Smith pitched a perfect ninth for his first save.
Nick Margevicius (0-1) pitched five-plus innings of one-run ball in his major league debut for San Diego but was the hard-luck loser. He was making the jump from Class A.
The 22-year-old Margevicius held the Giants scoreless on two hits until Steven Duggar singled leading off the sixth. He made way for Robert Stock, who allowed a double down the right-field line by Solarte, who played with the Padres from 2014 until being traded to Toronto before last season. He signed with San Francisco in February.
Margevicius allowed one run and three hits in five-plus innings, struck out five and walked none.
"It was incredible," Margevicius said. "It was everything you've dreamed of. It was pretty surreal for me. I would have liked to come away with a win, but I was very happy."
He hit two batters, including grazing Duggar across the nose leading off the game. Duggar was OK. He also hit Brandon Belt on the hand.
"They just got away from me," the pitcher said. "I wasn't trying to go up and in, they just got away."
Manager Andy Green said Margevicius "was great. Really good first outing in the big leagues. Very composed, even though he hit a couple guys. He was well-prepared, very intelligent approach to the hitters. Outstanding first effort."
Margevicius was promoted earlier in the day and became the second player from the 2017 amateur draft to make is big league debut. He was the third straight young lefty to start for the Padres, following Eric Lauer (23) and Joey Lucchesi (25), both of whom made their big league debuts last year.
Margevicius went 10-8 with a 3.60 ERA between Low-A Fort Wayne and High-A Lake Elsinore last year before making one postseason start with Double-A San Antonio.
Giants: Longoria fouled a ball off his calf and came out. He'll get Sunday off.
Giants: RHP Jeff Samardzija is scheduled to start the series finale Sunday. He's trying to bounce back from an injury-marred season in which he went 1-5 with a 6.25 ERA in just 10 starts.
Padres: RHP Chris Paddack, 23, is scheduled to make his big league debut. He went 7-3 with a 2.10 ERA between Class A Lake Elsinore and Double-A San Antonio as he bounced back from Tommy John surgery.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Arrieta likely to have season-ending procedure
Phillies pitcher Jake Arrieta said he "probably" will not pitch again this season if he has arthroscopic surgery for a bone spur in his right elbow. "This is what I have to do," he said.
Andrus gets 4 hits, Rangers beat Jays 7-3 to avoid sweep
Kolby Allard pitched 5 2/3 innings to win for the first time with Texas, Elvis Andrus had four hits and two RBI and the Rangers beat the Toronto Blue Jays 7-3 Wednesday to avoid a three-game sweep.
Sanchez mashes home run to center
Gary Sanchez crushes a three-run home run to center field in the first inning, his 26th home run of the season.
Santana adds insurance run to lead
Danny Santana hits a long fly ball that is able to carry enough to end up landing in the bullpen for a home run.
Mets place McNeil (hamstring) on IL, add Tejada
Mets All-Star second baseman Jeff McNeil was placed on the 10-day injured list Wednesday due to a mild left hamstring strain. The team called up Ruben Tejada from Triple-A to fill McNeil's spot.
Giants' Sandoval on IL after elbow flares up again
Giants infielder Pablo Sandoval has had an MRI and a cortisone shot for his right elbow, which has bothered him for several years and has flared up again.