KANSAS CITY, MO. — Nine hundred and four days had passed since Game 7, since Madison Bumgarner had gone legend with a five-inning relief performance on two days of rest, since Alex Gordon had been stranded on third base, since Pablo Sandoval had cradled a Salvador Perez foul pop and fallen onto his back for the final out of the World Series.

Nine hundred and four days, and so much had happened since then. The Royals won a World Series in 2015. Alex Gordon re-signed in Kansas City. A franchise grieved the loss of a young pitcher.

And yet, some things had not changed. Madison Bumgarner is still baseball’s closest thing to a living, breathing gunslinger, a 6-foot-5, 250-pound specimen hurling left-handed bullets that appear to come from nowhere. And on Wednesday night at Kauffman Stadium, that gunslinger, the Royals’ old World Series nemesis, was outdueled by Jason Vargas, a 34-year-old left-hander who spent the evening baffling the San Francisco Giants with a bag of 86 mph fastballs and diving changeups.

Vargas tossed seven scoreless innings in a 2-0 victory, continuing the masterful work of the starting rotation. In three starts, Vargas has allowed just one run, posting a 0.44 ERA while stretching his current scoreless innings streak to 14.2. On Wednesday, he finished with nine strikeouts, handing the baton off to Joakim Soria in the eighth inning.

One night after wasting a strong performance from Jason Hammel, the Royals (7-7) solved Bumgarner with a simple but satisfying formula: Dominant starting pitching. Two innings of perfect relief work. And just enough offense. In some ways, it felt like a throwback to 2014, when the Royals ripped off an unlikely World Series run in the same mold.

In 2014, that wondrous month ended at the hands of Bumgarner, who emerged from the bullpen in Game 7 and slammed the door shut in historic fashion. On Wednesday, the offense found a way scratch across a run in the bottom of the fifth.

With Paulo Orlando on third base and two outs, Mike Moustakas clubbed a hard chopper at Giants first baseman Brandon Belt, who was handcuffed by the baseball and couldn’t field it cleanly. As the baseball bounced away, Moustakas sprinted down the line and beat Bumgarner to the bag, sliding in headfirst for an RBI single.

Bumgarner has pieced together a string of 18 scoreless innings against the Royals, a stretch that began in Game 2 of the World Series in 2014. On this night, he lasted six innings before giving way to the Giants’ bullpen.

This was not an offensive breakout for a team that entered with just 39 runs in 13 games, the lowest total in the majors. But this was needed nonetheless. The Royals completed their first homestand with a 5-3 record. They will open a four-game series against the Texas Rangers on Thursday night.

The Royals had entered the evening batting .149 (13 for 87) with runners in scoring position, the worst mark in the major leagues. To reach such depths takes a confluence of poor performance and some rotten luck, and the latter surfaced in the second, when Cheslor Cuthbert came up with two on and two out smashed a baseball 111 mph into the glove of Giants third baseman Eduardo Nunez.

Eric Hosmer continued his early-season slide before a timely double in the eighth, which led to an insurance run when Perez dropped a single into center field.

The night ended with a save from Kelvin Herrera, who doused Salvador Perez with the Gatorade bucket.

Just like that, the Royals were back to .500.