The run-off pitted him against former president Sharif Sheikh Ahmed.
Mohamud garnered 190 votes against 79 for Sharif, according to a tally by an AFP reporter at the scene.
The two men were neck and neck in the first round of voting but Hassan Sheikh Mohamud emerged victorious in the second and final round.
"Hassan Sheikh Mohamud is the winner for today's presidency," parliament speaker Mohamed Osman Jawari announced.
Two other candidates, outgoing prime minister Abdiweli Mohamed Ali and Abdikadir Osoble, pulled out after the first round of the polls that mark the final stage of a UN-backed process aimed at setting up a new administration for the war-torn country.
Hassan Sheikh Mohamud was a largely unknown candidate who comes from the same Hawiye clan as Sharif. Analysts say he has been actively involved with Somalia's NGO community.
He is an academic, and a political and civic activist who has worked for several national and international peace and development organizations. – AFP