De Villiers, dashing batsman from South Africa, set the new landmark during an innings of 149 against the West Indies in Johannesburg.
He smashed eight fours and 10 sixes in beating the previous ODI record of 36 balls by New Zealand all-rounder Corey Anderson against West Indies last year.
Chris Gayle's 100 from 30 balls in the Indian Premier League in April 2013 is the fastest century in cricket history.
South Africa scored 439-2 as they registered their highest ever ODI score, beating the 438-9 in a win against Australia in March 2006.
The total was just four short of the all-time ODI record score of 443-9 set by Sri Lanka against Netherlands in July 2006.
Fastest ODI centuries
1. AB de Villiers (South Africa) - 31 balls against West Indies in Johannesburg on 18 January, 2015.
2. Corey Anderson (New Zealand) - 36 balls against West Indies in Queenstown on 1 January, 2014.
3. Shahid Afridi (Pakistan) - 37 balls against Sri Lanka in Nairobi on 4 October, 1996.
4. Mark Boucher (South Africa) - 44 balls against Zimbabwe in Potchefstroom on 20 September, 2006.
5. Brian Lara (West Indies) - 45 balls against Bangladesh in Dhaka on 9 October, 1999.