Ramirez had been designated for assignment by Baltimore on Wednesday.
The 25-year-old Ramirez was 0-2 with a 6.97 ERA in four games this season, including one start. He struck out 10 in 11 1/3 innings.
In two seasons with Baltimore, Ramirez was 1-10 with a 6.07 ERA in 21 appearances, including 13 starts.
The Orioles announced the trade during Monday's game against Detroit.