The deal leaves the Red Sox without their top two starters. Both teams announced the move a few hours after the struggling Red Sox said they sent their No. 1 starter, left-hander Jon Lester, to the Oakland Athletics with outfielder Jonny Gomes and cash for slugging outfielder Yoenis Cespedes and a 2015 draft pick.
The Red Sox also sent cash and minor league left-hander Cory Littrell to St. Louis.
Lackey is 11-7 with a 3.60 ERA in the fourth year of a five-year, $82.5 million deal.
Kelly is 2-2 with a 4.37 ERA in seven starts. He has made four starts since being activated from the disabled list on July 11. Craig is batting .237 with seven homers and 44 RBIs.
Lackey has had two strong seasons since being sidelined for all of 2012 after undergoing Tommy John surgery.
He was 10-13 with a 3.52 ERA last year when he pitched his second World Series-clinching game, allowing one run in 6 2-3 innings in a 6-1 win over the Cardinals in Game 6. In 2002, he won Game 7 for the Anaheim Angels over the San Francisco Giants, a 4-1 victory in which he gave up one run in five innings.
''I felt good about our club before we did these deals,'' Cardinals general manager John Mozeliak said. ''When you look at adding a top of the rotation starter with Lackey, getting somebody like Masterson, who has a history of eating innings, when you look at our rotation prior to this deal, sometimes our third, fourth and fifth starters were having trouble going deep in games, putting a lot of pressure on our bullpen.
''I think this will help alleviate some of that.''
Kelly joins a Red Sox rotation with a much different look than the one that began the season.
Lester, Lackey, Jake Peavy and Felix Doubront all are gone. Peavy was traded to the San Francisco Giants last Saturday and Doubront was sent to the Chicago Cubs on Wednesday. Only Clay Buchholz, an inconsistent right-hander, remains from the original group.
The 26-year-old Kelly was 5-7 with a 3.53 ERA as a rookie in 2012 and 10-5 with a 2.69 ERA last season.
He's ''not a finished product but really talented,'' Boston general manager Ben Cherington said, ''someone our scouts have liked for a long time.''
He said Kelly would immediately go into the rotation.
Craig brings more power to a weak-hitting outfield that was bolstered by the acquisition of Cespedes. In the past two seasons, Craig totaled 35 homers and 189 RBIs, hitting .307 in 2012 and .315 in 2013.
The 30-year-old Craig has been in a season-long slump after batting a major league-best .454 with runners in scoring position in 2013. He's gotten days off to help emerge from his slide with little success. He hasn't been the same since missing the last month of regular season with a left mid-foot strain but came back for the World Series, playing some designated hitter and first base.
Kelly and Craig both were hurt running to first, Craig when he landed awkwardly rounding the base and Kelly injuring his hamstring sprinting to beat out a bunt.
''When you think about the success this organization has had over the last three years, Joe Kelly and Allen Craig have been a major part of that,'' Mozeliak said. ''Pulling away from that is never easy.''
While the Cardinals make their playoff push, the Red Sox are in last place in the AL East and looking ahead to next season. With the departure of four veteran starters, several of their top prospects should get a long look the rest of the season.
AP Sports Writers R.B. Fallstrom in St. Louis and Bernie Wilson in San Diego contributed to this report.