The two games will count as home games for Miami.
All season-ticket holders affected by the change have the option to exchange tickets for the Pirates set with the Yankees exhibition.
There had been speculation since the tentative MLB schedules came out in September that the Marlins might play the Pirates in Puerto Rico. That became official on Thursday.
MLB Commissioner Rob Manfred announced May 31 will be recognized as Roberto Clemente Day.
Clemente, a native of Puerto Rico, celebrated a Hall of Fame career with the Pirates.
"We have been fortunate in the past to play at historic Hiram Bithorn Stadium, where you can feel the love and passion that the fans have for the game of baseball," Marlins owner Jeffrey Loria said in a statement. "We are very excited to return in 2016 to have the privilege to play on Roberto Clemente Day, as MLB honors the great baseball legend. This will be a special time for our entire organization."
The Marlins are no stranger to play in Puerto Rico. In June of 2010, they faced the Mets in a three-game set.
MLB also held regular-season games in San Juan in 2001, when the Rangers and the Blue Jays opened the regular season.
In 2003 and '04, the Montreal Expos played a portion of their home schedule at Hiram Bithorn Stadium. The Marlins faced the Expos during those years.
The Marlins are 7-2 all time in San Juan.
The 2016 celebration will mark the 15th annual Roberto Clemente Day, which was established by MLB to honor Clemente's legacy and officially acknowledge local club nominees of the Roberto Clemente Award.
The 2015 Clemente Award winner was Pirates five-time All-Star outfielder Andrew McCutchen.
Single-game tickets for the Yankees games and for the 2016 regular season will go on sale at FanFest, set for Feb. 20 at Marlins Park. More ticket information is available at marlins.com.
Joe Frisaro is a reporter for MLB.com. He writes a blog, called The Fish Pond. Follow him on Twitter @JoeFrisaro and listen to his podcast. This story was not subject to the approval of Major League Baseball or its clubs.