ABUJA/LAGOS, Aug 16 (Reuters) - Nigerian President Muhammadu Buhari signed into law an oil overhaul bill that has been in the works for nearly two decades, a presidential spokesman said on Monday.

The package overhauls nearly every aspect of the country's oil and gas production. The legislature cleared it for his signature last month.

The bill has been in the works since the early 2000s, but the sensitivity of potential changes affecting Nigeria's key source of revenue and foreign exchange has undermined all previous attempts at an overhaul.

Major fuel marketers and other observers had been alarmed by a provision that they said could give Africa's richest man, Aliko Dangote, an effective monopoly on fuel sales in Nigeria while the communities where oil and gas is produced had pressed for a larger share of oil money.

Analysts say the bill's approval this year was essential to attracting a shrinking pool of capital for fossil fuel development.

Amendments to the package allowed a series of concessions for oil companies to lure investment.

(Reporting by Libby George, Tife Owolabi and Felix Onuah Editing by David Goodman )