SCOTTSDALE, Ariz. -- A two-run double by Darwin Barney helped lead the Cubs past the D-backs, 7-5, on Monday afternoon at Salt River Fields.

Barney's hit came with one out in the seventh off D-backs left-hander David Holmberg. Jorge Soler followed with an RBI single.

The Cubs got on the board first in the third when David DeJesus singled with one out and after a Barney groundout, DeJesus scored when Nate Schierholtz delivered a double to left.

That lead didn't last long, though, as the D-backs rallied in the bottom half of the inning.

Pitcher Trevor Cahill drew a one-out walk, then Adam Eaton blasted a 3-2 pitch over the wall in left-center for a 2-1 lead.

The D-backs tacked on a run in the frame when Aaron Hill doubled and Paul Goldschmidt drove in pinch-runner Nick Ahmed with a single to right-center.

The two teams traded solo home runs in the fifth, with Cubs starter Jeff Samardzija hitting one to left-center and D-backs pinch-hitter Didi Gregorius hitting one to right.

The Cubs tied the game at 4 in the sixth on Welington Castillo's two-run homer off David Holmberg.

Samardzija, the Cubs' Opening Day starter, went 4 2/3 innings and allowed four runs on four hits.

This was Samardzija's second spring start against the D-backs.

"I like pitching against this team," Samardzija said. "They play ball the right way, they have an approach the right way -- the whole lineup does -- and they jump on your mistakes. I felt outstanding which was really exciting. It was probably the best I've felt all spring."

Cahill allowed just one run on three hits and struck out five in four innings.

Up next: The Cubs have Tuesday off before playing host to the Rockies on Wednesday at 3:05 p.m. CT at HoHoKam Stadium. Edwin Jackson will make the start for Chicago, and shortstop Starlin Castro is expected back in the lineup for the first time since Feb. 27. Castro has been sidelined because of tightness in his hamstring. An exclusive free audio webcast of the game will be broadcast on cubs.com.