(CNN) -- The election of Uhuru Kenyatta is a storybook ending for the son of Kenya's first president.
But despite his popularity at home, he is facing charges of crimes against humanity at the International Criminal Court over the 2007 post-election violence in Kenya, putting the West in a dilemma in its fight for human rights in the continent.
Kenyatta, 51, narrowly eked out a win, and will become the youngest president of East Africa's largest economy. His challenger, Raila Odinga, has said the vote is flawed, but lost a challenge brought in the Supreme Court.
Analysts say Kenyatta's victory signals a growing discontent against Western intervention in the continent.
In his victory speech, Kenyatta noted the sentiment.
"Today, we celebrate the triumph of democracy; the triumph of peace; the triumph of nationhood," he said. "Despite the misgivings of many in the world, we demonstrated a level of political maturity that surpassed expectations."
Africans have accused the International Criminal Court, based in The Hague, in the Netherlands, of targeting the continent's leaders.
"Kenya sent a loud message to the ICC ... don't interfere," said Ayo Johnson, director of ViewPoint Africa. "And it does not matter if you brand our leaders as criminals."
Grooming for power?
In retrospect, it appears Kenyatta's path from childhood may have been preparing him for his new role.
His earliest memories revolve around the state house -- the nation's equivalent of the White House -- where he scampered down hallways when his father, Jomo Kenyatta, was serving as the nation's first post-independence president.
Born in 1961, two years before Kenya officially got independence from Britain, his parents named him "Uhuru" -- Swahili for freedom -- in anticipation of the nation's liberation from colonial rule.
At a young age, he brushed shoulders with some of the nation's prominent figures. His online photo album includes receiving a history award from Mwai Kibaki at a young age, the man he is replacing as president.
Kenyatta attended high school in the capital of Nairobi, where he was a winger in a rugby team.
Two years after his father died in 1978, Kenyatta joined Amherst College in Massachusetts, where he studied economics and political science.
He returned home after graduation and launched a horticulture business, which he later sold, and focused on the extensive family businesses his father left behind.
His family's empire includes hundreds of thousands of acres of land, often a cause of resentment amid the grinding poverty in the nation.
Politics and mentors
Kenyatta dipped into politics as a fierce supporter of the Kenyan African National Union, which ruled the nation from Independence until 2002.
After his father's death, Daniel Arap Moi took over the leadership of the party and the nation. He took the younger Kenyatta under his wing, mentored him and secured him a position in his government.
When Moi decided not to run for re-election in 2002, he designated Kenyatta as his candidate of choice.
Kenyatta lost to current incumbent president, Kibaki, partly because of his ties to Moi, who was resented for overstaying his welcome as president.
Despite Kenyatta's loss at the polls, he became known for more than his father's last name.
When Kibaki sought to change the constitution to strengthen the president's powers, Kenyatta teamed up with then-opposition leader Odinga to rally against the change.
In 2005, voters shot down Kibaki's constitution draft, handing the two rivals a victory.
However, the two parted ways before the last election in 2007.
Kenyatta, who was not running for office then, threw his weight behind Kibaki, who was up against Odinga.
He later served in various positions in Kibaki's government, including finance minister and his latest role, deputy prime minister.
After the 2007 election
The last election stoked deep ethnic rivalries.
When Kibaki was declared the winner, Odinga alleged the vote was rigged, sending supporters battling on the streets.
The International Criminal Court has indicted Kenyatta for allegedly funding a local militia that conducted reprisal attacks at the time.
He has denied the charges, and vowed to cooperate with the court to clear his name.
His running mate William Ruto and two others are also indicted.
Kenya reneged on a deal to try the perpetrators in local courts, forcing the courts to step in.
A Western quandary
Before the 2013 election, Johnnie Carson, the top American envoy to Africa, warned that "choices have consequences," widely interpreted as a threat to Kenyans not to vote for him.
Carson's predecessor, Jendayi Frazer, slammed his stance against Kenyatta, describing it as "reckless and irresponsible."
"Kenyatta knows that he needs the United States, and the United States knows it needs Kenya," Frazer said. "While it (relations) might be awkward, there won't be a significant change in our policy stances toward Kenya or theirs toward us."
In a statement after the election, U.S. Secretary of State John Kerry applauded the vote -- but did not mention Kenyatta.
"We ... will continue to be a strong friend and ally of the Kenyan people," he said.
Kenyatta has said the indictment will not affect his ability to do his job and urged the international community to respect the will of Kenyans.
Analysts say the ICC indictment may have rallied citizens to Kenyatta's side in defiance of the West.
A majority of the court's investigations are focused on African nations.
"Many Africans have lost faith in ICC and view it as targeting African leaders and failing to discharge its justice among non-African leaders," Johnson said.
Kenyatta's trial is scheduled for July, while his running mate's is in May.
Kenya will become the second African nation after Sudan to have a sitting president facing charges at the International Criminal Court.