The experienced opener, deputising for neck injury victim Romesh Kaluwitharana, struck an unbeaten 142 to help his side reach a formidable total of 288 for 5.
And now Mahanama will be hoping for a place in Sri Lanka's starting line- up when they begin the defence of their trophy against England at Lord's on Friday.
The 32-year-old veteran of more than 200 one-day internationals had not originally been included in Sri Lanka's provisional 19-man squad.
But he hammered nine fours and four sixes in his 119-minute innings, which spanned the entire 50 overs.
He provided the backbone of Sri Lanka's progress by adding 131 in 26 overs with another of Sri Lanka's experienced campaigners Aravinda De Silva who made 66.
But it was in the final 12 overs that the Nottinghamshire attack really suffered as Sri Lanka added 108 runs, with Mahanama and Arjuna Ranatunga putting on 60 in just eight overs.
The early departures of Tim Robinson and Jason Gallian, together with the absence of Paul Johnson meant that the outcome was never in doubt.
The Zimbabwe coach, David Houghton, criticised his batsmen for allowing a seriously depleted Derbyshire side to win the warm-up match at Derby by five wickets.
The tourists' lack of match practice showed as they failed to come to terms with a slow pitch that made stroke play difficult, but Houghton made no excuses after they had been bowled out for 178 by an attack that was without front line seamers Dominic Cork and Kevin Dean.
"We just had a bad day," Houghton admitted. "No one was knocking the ball around for singles and it was almost schoolboy cricket." Derbyshire finally won with two balls to spare.
Kenya's batsmen produced some sparkling stroke play at Bristol to give themselves a confidence-boosting win with four wickets and five deliveries to spare over Gloucestershire before their World Cup opener against Zimbabwe.Reuse content