The Mets sent reliever Tommy Hunter and minor league catcher Matt Dyer to the Rays in exchange for Hill, according to the clubs.
Hill has posted a 6-4 record and 3.87 ERA over 19 starts for the Rays this season. He had been scheduled to start Friday's game against Cleveland before being shipped to New York.
The 41-year-old Hill has pitched just 95 1/3 innings this year due to limits imposed under the Rays' pitching strategy. This will be his 11th MLB team over his 17-year career.
"I think a lot of people in the game know the name -- guy that's been around, pitching good baseball, pitching playoff baseball," Mets manager Luis Rojas told reporters. "It's a great fit, great acquisition. Our front office is being diligent. One of the needs we've talked about is our starting pitching need, and this is a guy that fits right in."
The first-place Mets were in desperate need of help in the rotation, with ace Jacob deGrom and left-hander David Peterson on the injured list. Carlos Carrasco and Noah Syndergaard, meanwhile, have struggled in their respective rehabilitation processes.
The Mets have used 15 different starting pitchers in the 2021 season, tied with the division rival Miami Marlins for most in the majors this year.
Hunter, 35, previously pitched for Tampa Bay in 2017. The 14-year veteran made four appearances for the Mets this season and didn't allow a run.
The 23-year-old Dyer was drafted by the Mets in the fourth round of the 2020 amateur draft. He was hitting .194 with seven home runs and 20 RBIs for Class A St. Lucie this season.