PITTSBURGH — Joe Panik hit a bases-loaded triple, Mac Williamson launched a 446-foot home run and the San Francisco Giants beat the Pittsburgh Pirates 5-3 Thursday for their 12th win in 14 games.

The Giants took three of four at PNC Park and are 40-17 overall since April 21, the best record in the majors.

After hitting a key double late in Wednesday night’s win, Panik put the Giants ahead 3-1 with his triple in the third inning. Williamson followed with an RBI single.

Williamson connected for his second home run of the season in the sixth.

Albert Suarez (3-1) gave up two earned runs in five innings. Santiago Casilla struck out three in the ninth for his 16th save.

Jonathon Niese (6-5) was tagged for five runs in six innings.

MARLINS 4, CUBS 2: Giancarlo Stanton homered in the fourth inning and singled home the go-ahead run with two outs in the eighth, helping host Miami send Chicago to a fourth straight loss.

Stanton’s two hits bumped his average up to .216.

The Cubs still have the best record in the majors, despite their longest losing streak of the season.

The game marked the start of a season-high 11-game trip for the Cubs, and came after they were swept in a three-game series at Wrigley Field by the Cardinals.

BRAVES 4, METS 3: Adonis Garcia hit a go-ahead, two-run homer off Addison Reed in the eighth inning and host Atlanta beat the Mets for the fourth straight time in a week.

Atlanta has improved its NL-worst record by winning seven of eight.

The Mets have lost four of six.

A.J. Pierzynski drove in two runs off Matt Harvey to boost the Braves, who posted a three-game sweep at Citi Field last weekend.

PADRES 7, REDS 4: Derek Norris hit a three-run homer that completed visiting San Diego’s sixth-inning comeback, and the NL’s highest-scoring team in June rallied for a win in a matchup of last-place teams.

The game marked the beginning of the Reds’ biggest weekend of the season. Hits king Pete Rose will be inducted into the Reds’ Hall of Fame and his No. 14 will be officially retired.

AMERICAN LEAGUE

TIGERS 5, MARINERS 4: Pinch runner Cameron Maybin easily scored on a bases-loaded wild pitch by Steve Cishek with two outs in the 10th inning, giving Detroit a four-game sweep at home.

It was Detroit’s first four-game sweep of Seattle since August 1980 at Tiger Stadium.

Nelson Cruz homered twice and Chris Iannetta and Leonys Martin later hit back-to-back drives for the Mariners, who lost their sixth in a row.

Robinson Cano struck out with a runner on third to end the Seattle 10th.

INTERLEAGUE

PHILLIES 7, TWINS 3: Struggling Freddy Galvis homered as part of a career-high five-RBI day and Philadelphia ended a nine-game losing streak with a win at Minneapolis.

Cesar Hernandez tied a career high with four hits and Ryan Howard homered as part of his third multiple-hit game of the season, and first since April 29.