Source: Dodgers eyeing Zack Greinke

The Los Angeles Dodgers were closing in Saturday on signing the top free-agent pitcher on the market, Zack Greinke, a source told ESPN.

The deal is worth approximately $147 million over six years, a source told ESPN.

The contract will pay Greinke more than the $144 million extension Cole Hamels signed with the Philadelphia Phillies in July, and will be the largest ever for a right-handed pitcher.

In total dollars, Greinke's new deal would be the second most lucrative in history for a pitcher, trailing only the original $161 million deal signed by CC Sabathia in 2009.

Grienke will also have a full opt-out clause in his new deal, a source told ESPN. He will not have a no-trade clause, but the right-hander can opt out after the first year if he is traded.

The Dodgers had been widely viewed as the favorite to sign the 29-year-old Greinke, a one-time Cy Young Award winner, until recent days, when the Texas Rangers emerged as an equally strong suitor for the right-hander.

In fact, as recently as Thursday, on the final day of the winter meetings, Dodgers general manager Ned Colletti appeared greatly discouraged by the course his team's negotiations with Greinke and his agent, Casey Close, had taken.

Asked if he was on the "doorstep" of acquiring Greinke, Colletti replied: "We're not on the front lawn. ... We're barely out of the car at the curb. It's better than driving around the neighborhood looking for the house. We know where the house is located. We just can't seem to get out of the car."

The Rangers have been informed they are out of the running for Greinke, a source told ESPN.

Greinke compiled a 15-5 record with a 3.48 ERA and 200 strikeouts in a 2012 season he split between the Milwaukee Brewers and Los Angeles Angels.

The Dodgers prioritized starting pitching shortly after the season ended, with the intention of finding a No. 2 and, maybe, a No. 3 starting pitcher to slot behind ace Clayton Kershaw.

The team viewed Greinke as clearly the best pitcher on the market, with Anibal Sanchez a distant second. In recent days, the Dodgers had grown discouraged by what they viewed as an astronomical asking price on Greinke, but apparently his representatives lowered their sights in the past 36 hours.

The team has a 5 p.m. ET Sunday deadline to come to terms with left-hander Ryu Hyun-jin or he would return to pitch in his native South Korea and the Dodgers would be refunded their $25.7 million posting fee. If the Dodgers can reach a deal with Ryu's agent, Scott Boras, their offseason work would be all but complete.

Depending what happens with Ryu and a couple of recovering pitchers, the Dodgers now could be in position to deal a couple of veteran starting pitchers, with Chris Capuano and Aaron Harang the most likely names to be moved. The team isn't sure whether Chad Billingsley and Ted Lilly, both of whom are recovering from arm injuries, will rejoin its rotation next season.

Los Angeles took on more than $300 million in salary obligations in a series of trades last July and August that brought Hanley Ramirez from the Miami Marlins and Adrian Gonzalez, Carl Crawford and Josh Beckett from the Boston Red Sox, among others.

The driving force for all their spending is a massive TV deal the team is in the process of negotiating. The Dodgers are in discussions with at least two media companies about a new package that could bring them somewhere in the neighborhood of $6 billion over the next 25 years, according to reports.

ESPN.com's Jim Bowden, ESPNLosAngeles.com's Mark Saxon and ESPNDallas.com's Richard Durrett contributed to this report.