CHICAGO (AP) — The Texas Rangers won the Ryan Dempster sweepstakes, acquiring the Chicago Cubs ace for two minor leaguers moments before Tuesday’s trade deadline.

The AL West leaders fortified their rotation for the stretch run, sending infielder Christian Villanueva and pitcher Kyle Hendricks to Chicago. Dempster, who had power to block deals, had refused to approve a trade to Atlanta last week. The Los Angeles Dodgers and New York Yankees also tried to land the 35-year-old righty.

Dempster was 5-5 with a 2.25 ERA in 16 games for the Cubs and can become a free agent after the season. He was one of several players Chicago traded in a 24-hour span it sent pitcher Paul Maholm and outfielder Reed Johnson to Atlanta and catcher Geovany Soto to Texas.

Teams had until 4 p.m. EDT to complete trades without waivers. From now until the end of the season, clubs have a chance to claim players before they are dealt.

With a strong season that included a 33-inning scoreless streak, Dempster was one of the most attractive pitchers on the market. The Rangers were looking for pitching help even though they began the day leading with a 59-42 record and a 3½-game lead over Oakland in the AL West.

The Dempster trade came less than a week after the division rival Los Angeles Angels got former Cy Young winner Zack Greinke in a swap with Milwaukee. Many fans expected Texas to counter with a big move, and the Rangers pulled it off.

The two-time AL champion Rangers needed help with their rotation. Right-hander Colby Lewis underwent surgery Friday to repair a torn flexor tendon in his elbow and will miss the remainder of the season. Roy Oswalt has struggled, too, since signing as a free agent in midseason.

The Cubs had agreed to deal him to Atlanta last week, but Dempster turned down a chance to join the contending Braves. Either way, it was clear his time in Chicago was coming to an end.

With a contract set to expire after the season ends, Dempster simply wasn’t part of the plan with the Cubs in a rebuilding mode. They hired president of baseball operations Theo Epstein and general manager Jed Hoyer, hoping they could put together the first championship since 1908 after they helped build two title winners in Boston, ending a long drought there.

This trade is just the latest in a series of moves for a franchise that dealt the troubled Carlos Zambrano to Miami in the offseason and hired manager Dale Sveum to replace Mike Quade. They’re trying to stock up on prospects, and that meant saying goodbye to a popular team leader who is active in the community.

Dempster and his wife, Jenny, formed The Dempster Family Foundation in Chicago to help families with children born with DiGeorge Syndrome after daughter Riley was born with the chromosomal anomaly associated with numerous defects.

Dempster’s career got a big boost in Chicago. He was coming off Tommy John surgery and was released by the Reds when the Cubs signed him before the 2004 season, and he pitched out of the bullpen when he returned in August.

He opened 2005 in the starting rotation but quickly replaced LaTroy Hawkins as the closer and remained in that role for two more seasons. When the Cubs moved him back to the rotation in 2008, he responded with a career-high 17 wins and a 2.96 ERA for their most recent division winner, and he’s been steady ever since.