David Krejci had two goals and two assists and the Boston Bruins snapped out of a scoring funk to beat the St. Louis Blues 6-5 Friday night and hang onto third place in the Atlantic Division.

Loui Eriksson got his 500th career point with a goal and an assist and Patrice Bergeron scored his 30th this season for the Bruins, who totaled 10 goals while dropping six of their previous seven games. They're a point ahead of Detroit, which beat Minnesota 3-2, with four games remaining.

Paul Stastny had a goal and an assist and Alexander Steen and David Backes each had two assists for the Blues. St. Louis ended a five-game winning streak, during which it allowed one goal and recorded for consecutive shutouts. The Blues are second overall in the Western Conference with 101 points and have four games to go.

Brian Elliott allowed five goals in two periods and was replaced by Jake Allen to start the third. The Blues cut the deficit to 5-4 before Bergeron's goal with 3:24 remaining, and Kevin Shattenkirk again cut the gap to one with 20 seconds remaining. Elliott entered with an NHL-leading 1.92 goals-against average and was seeking his 10th consecutive victory.

Krejci's four-point game was a season best for the Bruins, who have been much better on the road (25-12-3) than at home (16-17-5). He had a pair of three-point efforts in October.

Stastny leads the NHL with 16 points in 11 games since March 9.

Jaden Schwartz started the scoring on an odd-man rush off a saucer feed from Jori Lehtera, but the lead lasted just 41 seconds. Goals by Eriksson and Krejci in a span of three shots put the Bruins ahead in the first, with John-Michael Liles assisting on both.

Following Stastny's equalizer in the second, the Bruins got goals from Matt Beleskey, Frank Vatrano and David Krejci.

Robert Bortuzzo also scored for the Blues.

Tuukka Rask made 25 saves for Boston.

Notes: Elliott had allowed one goal in 93 shots over four games since returning from a lower-body injury. ... Blues rookie F Robby Fabbri (lower body) missed his first game but skated earlier Friday and is not expected to be out long. ... F Jimmy Hayes, scoreless in 15 games, was among the Bruins' scratches. ... Bruins F Kevan Miller (lower body) did not return after getting checked by Magnus Paajarvi in the first. ... Attendance of 19,250 was the Blues' 19th sellout.