Ortiz was at the Dial Discotheque in Santo Domingo, his hometown, Sunday night.
The two men fled but did not get far.
The operator of the motorcycle that was carrying the gunman was captured and beaten by a crowd of people at the bar, authorities said. He first underwent surgery at a hospital in the Dominican Republic, where "Big Papi" was born and raised.
"David arrived at Massachusetts General Hospital last night and underwent a successful second surgery".
Ortiz is said to be "stable, awake, and resting comfortably".
Ortiz has been alert, has spoken to his family and "even flashed that smile", his media assistant, Leo Lopez, told ESPN.
The Red Sox said in a statement that Ortiz was wounded in the "lower back/abdominal region" and that the team offered his family "all available resources to aid in his recovery". But the gunman has not been arrested, and investigators were trying to establish whether Ortiz was the target. He was stabilized and then flown to Boston and taken by ambulance, with police escort, to Massachusetts General Hospital.
He led Boston Red Sox to three World Series championships and hit 541 home runs.
"He finds himself in a good state of mind and is waiting to travel to Boston ... to see his personal doctors and his wife", said Dr. Jose Abel Gonzalez, one of the surgeons who saved the All-Star's life. "But I'm so disappointed to know that someone like David, who saved so many lives, can have someone after his life".
"Six years ago, David Ortiz's spirit and resolve helped us all begin to heal from the Boston Marathon bombing", Obama added of the player, who made a rousing speech calling Boston "our f- -king city" after the 2013 terror attack.