Mr Obama was inadvertently struck by someone’s elbow during the game on Friday morning, the White House said.
The US president was treated in the doctor’s office of the White House following the game at Fort McNair, in Washington DC.
Later, Mr Obama was seen at the White House holding what appeared to be an ice pack to his lip.
“After being inadvertently hit with an opposing player’s elbow in the lip … the president received 12 stitches today, administered by the White House Medical Unit,” White House spokesman Robert Gibbs said in a statement.
Mr Obama was given a local anaesthetic while receiving the stitches, he added.
“The medical unit that treated Obama used a smaller filament than typically used, which increases the number of stitches but makes a tighter stitch and results in a smaller scar,” added Mr Gibbs.
Mr Obama was playing basketball with his personal aide Reggie Love – who played basketball for Duke University – and other members of his family on what is the thanksgiving holiday in United States.
He was photographed in a grey T-shirt and jogging bottoms leaving the basketball facility, holding his bottom lip.
A few hours later, reporters who had gathered on the White House driveway for the arrival of the Christmas Tree saw the president in an upstairs window, pressing what appeared to be a cold compress against his mouth.
The president has been a long time player of the sport, and has even been seen to take to the court with Cabinet members.