Every Yankees starter had at least one hit, and five had multi-hit games. Their 16 hits matched a season high.
Castro scored a pair of runs, drove in another and lifted his average to .351. Aaron Judge scored two runs, bringing his total to an American League-leading 32.
Royals left-hander Jason Vargas (5-2) entered the game with a major-league-best 1.01 ERA, but he left it with a 2.03 ERA, giving up more earned runs (six) in four innings than he had in his previous 44 2/3 innings (five).
Hicks' three-run homer with two outs in the fourth gave the Yankees a 5-0 cushion that the Royals could not overcome, and the Yankees kept adding on.
Pineda (4-2), who lost to the Royals twice last season, was removed in the seventh after giving up a single to Brandon Moss and third baseman Chase Headley committed two errors, fielding and throwing, on one play. Alcides Escobar's sacrifice fly scored Moss for an unearned run.
Pineda allowed four runs, three earned, on six hits with two walks and five strikeouts in six-plus innings.
Cheslor Cuthbert drove in two runs in the ninth and Mike Moustakas another, forcing the Yankees to summon Dellin Betances to get the final out and his first save of the season.
The Yankees (24-13) picked up a game on the Baltimore Orioles and lead the American League East by 1 1/2 games. The Royals (16-23) own the worst record in the AL.
Vargas had given up one earned run over 26 2/3 innings in his first four starts at Kauffman Stadium, a microscopic 0.36 ERA.
It took the Yankees less than inning to pin another run on Vargas' home ledger. Brett Gardner led off the game with an opposite-field single and raced home on Castro's double.
Vargas gave up five runs in a 49-pitch fourth inning when the Yankees sent 10 men to the plate.
Castro's one-out double started it and Vargas walked Judge. After Vargas retired Headley on a fly ball to center, Didi Gregorius singled home Castro.
Then came the big blow as Hicks took a 2-2 Vargas pitch out to left for a three-run homer.
Chris Carter singled and scored on Gardner's triple to the right field corner to make it 6-0 before Vargas could close out the inning.
The Royals got two runs back in the fourth when Salvador Perez homered, his ninth.
The Yankees, however, answered that with four runs in the fifth off Peter Moylan. The inning included Headley and Gregorius run-producing singles. Carter picked up an RBI on a fielder's choice groundout and Gardner added a sacrifice fly, making it 10-2.
Whit Merrifield hit his fourth Royals' homer in the fifth.
NOTES: Royals RHP Ian Kennedy, who is on the disabled list with a right hamstring strain, will likely be activated Saturday for a start at Minnesota. Kennedy threw a side session and tested his hamstring in pitchers fielding practice before the game with no problems. ... Yankees manager Joe Girardi opted to start LF Brett Gardner Wednesday because he's "been hot" over Jacoby Ellsbury, who will start Thursday. Gardner went 2-for-4 with two RBIs. ... Royals CF Lorenzo Cain stole his American League-leading 11th base in the first inning. ... Yankees LHP Jordan Montgomery and Royals LHP Danny Duffy are the Thursday probables for the series finale.