A recently released Wanganui prisoner has been foiled in an alleged attempt to throw two cannabis-filled tennis balls into the prison unit he was released from in May.

After receiving a tipoff, police were waiting outside Wanganui Prison last Thursday when the former prisoner was dropped off by a car about 9.30am.

Police stopped the car's driver and recovered two tennis balls containing about 65 grams of cannabis with a value of more than $3000.

Both men were arrested and charged with possession of cannabis with intent to supply.

They would appear in court next week.