Updated

Jaime Garcia looked as good as new Sunday afternoon.

The St. Louis left-hander, back after missing 64 games with a strained left shoulder, struck out a career-high 10 batters in a strong eight-inning stint in the Cardinals' 6-3 loss to Pittsburgh in 19 innings.

Garcia, who last started on June 5, allowed just five hits and two unearned runs in a 107-pitch outing. He did not walk a batter.

"It's just one game, but it feels (better) than before," he said. "The whole time my arm felt pretty good. I was able to keep the ball down and get ahead in the count."

Garcia, who gave up 10 runs in two starts over eight innings before going on the disabled list, set the side down in order in four of his eight innings.

"He was impressive, he was great," St. Louis manager Mike Matheny said. "He was as good as I've seen him this year. It's a great sign."

Pittsburgh third baseman Pedro Alvarez broke a 3-3 tie with a homer in the 19th inning to help the Pirates win the longest game in the majors this season.

It took 6 hours, 7 minutes to finish, trying the longest contest by time, matching a game between Baltimore and Boston on May 6.

Both teams scored a run in the 17th, and each club used eight pitchers.

Alvarez slammed the go-ahead homer off Barret Browning (1-3). Andrew McCutchen added a two-run single later in the inning.

Wandy Rodriguez (8-12), who was set to start for the Pirates on Monday night at San Diego, got the win with two scoreless innings of relief. It was his first win as a reliever in 232 major league appearances.

"That was a backyard tug-of-war," Pittsburgh manager Clint Hurdle said. "We kept playing defense, we kept pitching. At the end of the day, we finally got some separation in the 19th inning.

About 9,000 fans from the original crowd of 43,412 stayed until the end.

Each team had played a marathon in recent years. St. Louis went 20 innings against the Mets on April 17, 2010, and Pittsburgh played 19 innings at Atlanta on July 26, 2011.

The Pirates improved to 4-0 in extra innings this season. They moved two games ahead of St. Louis in the race for the last wild-card spot in the NL. The Cardinals have lost three of four overall.

"It was a battle all around on both sides," McCutchen said. "They came to play and we were just able to get the win. It feels good."

Alvarez picked on a slider from Browning and drove it 408 feet.

"It felt good out of my hand," Browning said. "It just stayed up. I don't think I've ever been this disappointed. I just didn't do my job."

Both teams ran out of position players after the 18th inning.

Garrett Jones gave Pittsburgh a short-lived 3-2 lead with a bases-loaded infield single in the 17th. He drove in pitcher James McDonald, who singled as a pinch-hitter, the first of his career.

"It was just luck," McDonald said. "You know how hard pinch-hitting is? So it was pretty much luck."

But St. Louis came right back to tie it on a sacrifice fly by Tony Cruz that brought in pinch-runner Ryan Jackson. Yadier Molina and Skip Schumaker began the 17th inning with singles.

Pittsburgh had a pair of hits in the 16th but Molina threw out Jose Tabata trying to steal and reliever Joe Kelly induced McCutchen to ground out to end the inning. Reliever Edward Mujica got Neil Walker to ground into a double play to end the 11th. Kelly allowed four hits and one run in 5 2-3 innings of his first relief appearance.

Carlos Beltran put St. Louis in front with a two-run double in the fourth, and also stole three bases, tying a career high. Beltran leads the NL with 85 RBIs.

"Twenty innings or nine innings, a loss is a loss," Beltran said. "We had the opportunities. It just didn't happen."

Pittsburgh starter Jeff Karstens gave up two runs on two hits over seven innings. He struck four and walked one.

The Pirates scored twice in the sixth to tie it on a pair of infield singles and Garcia's throwing error. Clint Barmes reached on an infield hits and Garcia mishandled a bunt attempt by Karstens. Josh Harrison drove in Barmes with a sacrifice fly and McCutchen followed with an infield single.

Chris Resop led the Pirates' bullpen crew with three scoreless innings. Kevin Correia and Jared Hughes added two scoreless innings each.

Hurdle said he has yet to select a starting pitcher to replace Rodriguez on Monday.

"I'll come up with something tomorrow," he said.

NOTES: 1B Allen Craig extended his hitting streak to nine games with a single in the fourth inning. .. Jon Jay snapped an 0 for 14 skid with a two-out single in the 13th. ....Garcia's 10 strikeouts are the most by a St. Louis left-hander since Mark Mulder fanned 12 on May 9, 2005 against Los Angeles. ... The Cardinals sent RHP Trevor Rosenthal to Triple-A Memphis prior to the game to make room for Garcia. .... St. Louis plays host to Houston in a three-game set beginning Tuesday. Wainwright (11-10, 3.87) will face Lucas Harrell (10-8, 3.81) in the series opener. Wainwright drew a walk as a pinch hitter Sunday.