After four years in minor league baseball, Ryan Flaherty is getting his best shot at the big leagues.

The Baltimore Orioles took the 25-year-old Flaherty, a former Deering High School and Vanderbilt University standout, in the Rule 5 draft at baseball’s Winter Meetings Thursday morning in Dallas.

The Chicago Cubs made Flaherty the 41st overall selection in the 2008 amateur draft and he rose through their system, making stops at five different affiliates while playing four infield positions as well as corner outfield spots.

He spent much of last season at Double-A Tennessee — batting .305 with 14 home runs and 66 RBI in 83 games to become a Southern League All-Star — before being promoted to Triple-A Iowa in July, where he hit .237 with five homers and 22 RBI in 49 games.

Under terms of Rule 5, the Orioles pay the Cubs $50,000 for Flaherty, who must remain on Baltimore’s 25-man roster all season and be active for at least 90 days. Otherwise, Flaherty returns to the Cubs for half the purchase price.

“I’m excited about it,” said Flaherty, who has been working out in Nashville with some college buddies and plans to return to Maine next week. “It’s a great opportunity.”

Dan Duquette, the Orioles general manager, told reporters after the draft that “Ryan is a high draft pick from an excellent college program and we really like his bat. He has a reasonable chance to contribute at the major league level this season.

“If you’re a ballplayer from Maine, that means you really want to be a ballplayer,” Duquette added.

Duquette and Orioles manager Buck Showalter called Flaherty shortly after the draft to welcome him to the organization.

Having played four pro seasons after signing out of college, Flaherty knew he might be changing uniforms after the Cubs decided not to protect him on their 40-man roster. The Orioles hold spring training in Sarasota, Fla., and are scheduled to play nine dates at Fenway Park against the Red Sox.

“It would be nice to be able to play close to home,” Flaherty said. “I mean, Baltimore wouldn’t be that far. But I’ll just take it step by step and see how all this plays out.”

Under terms of the new collective bargaining agreement, the Major League minimum salary in 2012 will be $414,000.

“Now,” Flaherty said, “I just have to go out and make the team.”