CHICAGO -- The Cubs filled a hole in the rotation Friday, agreeing to a two-year, $32 million contract with free-agent right-hander John Lackey. The contract will be finalized pending a physical.

FOXSports.com first reported the deal. The club would not confirm.

• Cubs Hot Stove Tracker

Lackey, 37, who was 13-10 with a 2.77 ERA in 33 starts with the Cardinals last season, is close friends with Cubs starter Jon Lester and knows Chicago president Theo Epstein from their days together in Boston.

The Cubs entered the offseason in search of depth for the rotation behind Lester, National League Cy Young Award winner Jake Arrieta, Jason Hammel and Kyle Hendricks. They had been in talks with free agent Jeff Samardzija about a possible return, and Epstein said Friday that dialogue was ongoing with the right-hander. However, Samardzija is reportedly receiving offers of $90-100 million, which may price him out of the Cubs' budget.

"We need to focus on the free agents who make sense for us and try to get them at a cost that makes sense for us given our roster and payroll structure and how things look, not just in '16 but over the next several years," Epstein said Friday before the Lackey news. "We'll stay focused on that."

Video: Muskat on the Cubs' possible Winter Meetings moves

Last winter, the Cubs signed Lester to a six-year, $155 million contract, and this offseason, had been exploring both the free-agent market and possible trades. They did talk to David Price, who signed a seven-year, $217 million contract with the Red Sox.

"Right now, we just couldn't compete at that level," Epstein said of Price's deal. "I still think we can do plenty of things that will help our club in 2016 and beyond that make sense for us. That type of commitment made sense for them and they got themselves a heck of a pitcher."

Lackey has a 165-127 record over 13 seasons, and spent the last two with the Cardinals, compiling a 16-13 mark and 3.10 ERA in 43 starts. He was with the Red Sox from 2010-14, then was dealt to the Cardinals in July 2014 for Allen Craig and Joe Kelly. The Cardinals did make a qualifying offer to Lackey.

Lester, who pitched for the Red Sox from 2006-14, recorded his first Major League hit with an infield single off Lackey on July 6 to end an 0-for-66 career hitless streak that began in 2006. There was a little trash talking involved before the game, and the two celebrated afterward.

Video: [email protected]: Lester tallies single for first MLB hit

David Ross also was a teammate of Lackey's in Boston, and speaking on MLB Network Radio on Friday, the Cubs' catcher said he was thrilled at being reunited with the pitcher.

"He's one of those guys, he puts a smile on my face every time I walk into the locker room and see him," Ross said. "I'm super happy today."

Ross said Lackey is a "big game guy," and not to let his age fool you.

"He's getting better," Ross said of the right-hander. "He developed another pitch -- he's a got a little cutter, slider thing that he's throwing now off his fastball. He pitches so well with his fastball that you have to commit to that heater."

Ross also expected the veteran, who started and won the clinching game of the World Series for two teams (Angels in 2002, Red Sox in 2013), to help the young pitchers on the Cubs' staff.

The contract with the Cubs comes six years after Epstein signed Lackey to a five-year, $82.5 million deal in December 2009 with the Red Sox. That deal included a 2015 club option at the Major League minimum salary if Lackey missed significant time with surgery for a pre-existing elbow injury in 2010-14. Lackey did undergo Tommy John surgery after the 2011 season, and missed all of 2012.

The Cardinals will receive a Draft pick as compensation for the Cubs signing Lackey, who received a qualifying offer from St. Louis. Chicago had the 28th pick in the first round.

On Friday, Epstein said the Cubs' goal was to sign a pitcher to a contract that makes sense, and the Lackey deal would fit that, plus allow the team room to still acquire an outfielder. The Cubs are in the market for a center fielder following Dexter Fowler's departure via free agency.

Epstein did expect more action in Nashville at the Winter Meetings, which officially begin Monday.

"I think the Meetings will be pretty wild," Epstein said.

Fantasy spin | Fred Zinkie (@FredZinkieMLB)

By signing with the Cubs, Lackey has an excellent opportunity to be a valuable back-of-the-fantasy-rotation asset in shallow leagues during 2016. The right-hander will be hard-pressed to replicate his 2.77 ERA from last season, but a mark in the mid-3s -- close to last year's 3.59 FIP -- should be attainable. And given Chicago's standing as a young, talented bunch on offense and defense, the veteran would seem to be in solid position for a lofty win total.