This is after votes from about 80 per cent of constituencies were counted, the electoral commission said on Friday.
With no reliable opinion polls in the southern African state, few experts have been keen to call a winner in the contest to succeed Michael Sata, who died in office in October aged 77.
Results from 121 out of 150 constituencies showed Patriotic Front candidate Lungu, 58, had 48.72 percent of votes, compared to 46.85 percent for Hichilema, 52, a wealthy economist from the United Party for National Development.
Defence and justice minister Lungu polled 701,089 votes and Hichilema had 674,185 out of just over 1.43 million ballots cast, the Electoral Commission of Zambia (ECZ) said.
Turnout was around 34 percent as heavy rains disrupted voting across much of the landlocked country. Observers said the election was conducted in a fair manner.
With another election due late next year when Sata’s term would have ended had he not died in office, the winner will have little time to turn around a stuttering economy in one of Africa’s most promising frontier markets.
Zambia has averaged 6-7 percent growth as the mining sector boomed but that slowed to 5.5 percent last year, the International Monetary Fund says, and could ease further with the price of copper reaching a 6-year low this month.
Lungu, a former lawyer with a laid-back, populist style, has used his campaign to tap into the grassroots support of his predecessor Sata, promising voters cheaper food and fuel.
Hichilema, one of Zambia’s wealthiest businessmen, has said if he wins he will draw on his experience in the private sector to attract foreign investment and diversify an economy, where copper accounts for 70 percent of export earnings.