"And just because it's a job of a father to embarrass his daughters, I've got one last job," President Obama said at the end of his speech to hundreds gathered in the East Room.
"It just so happens that we celebrate our country's birthday on the same day that we celebrate my oldest daughter's birthday," Obama added before leading the audience to sing "Happy Birthday" to Malia, who later joined her father on stage to give him a celebratory hug.
Singer Janelle Monáe gave the First Daughter a birthday shout out earlier in the evening.
"We want you back, Mr. President! We don't want you to leave," she said.
During his final July Fourth celebration at the White House before he leaves office, Obama called America a "miracle" that needed to be defended and nurtured.
President Obama made the brief comments to hundreds of people gathered inside after rain forced officials to cancel an annual barbecue on the South Lawn for military service members, veterans and their families.
It was the second straight year that weather scuttled the picnic.
ABC News' Benjamin Siegel contributed to this report.