Under the new law, an anti-doping agency will be established and athletes found taking drugs can be fined up to 900 euros and jailed for a year.
Anyone found to be providing banned products faces a 26,000 euro fine and up to three years in prison.
The measures have reached the statute books 10 days before a deadline imposed by the World anti-doping agency - Wada.
"I am confident that Wada will look upon the passage of our anti-doping law favourably as a sign of our unwavering commitment to meeting the highest international standards," Kenyatta said.
"I want to urge our athletes and sportsmen and women to hold themselves to the highest possible code of conduct."
Kenyan athletes topped the medals table at last summer's World Championships in Beijing with seven gold, six silver and three bronze. There had been concern that the likes of David Rudisha, Ezekiel Kemboi and Nicholas Bett would be unable to compete at the Olympics after Kenyan MPs missed two previous Wada deadlines on 11 February and 5 April.
Since 2011, 40 Kenyan athletes have been caught taking drugs. Two were exposed during the World Championships. Koki Manunga and Joyce Zakary were immediately suspended by the International Association of Athletics Federations - the IAAF.
However, despite the poor recent record, Kenyatta said the cases of doping were not indicative of a widespread problem in the country.
"I know that the few cases of cheating we have encountered in the past are not a reflection on the integrity of all our athletes," he said.
Kip Keino, the head of Kenya's national Olympic committee welcomed the government's move. He told RFI: "I'm happy that the government have taken action. They've done a wonderful job."
The 76-year-old former Olympic champion added: "We at the committee appreciate that the youth of our country will be able to participate in the Olympic Games in the summer. "We feel that the law against drug abuse has been taken care of by our government and I'd like to thank the president and MPs for what they have done."