Former Plaid Cymru AM Simon Thomas has avoided jail after pleading guilty to making indecent images of children.
Thomas, also a former MP, admitted making more than 500 indecent photographs and 77 films - some involving children as young as six.
He quit the Senedd and his party after being arrested in July.
Thomas was given a 26-week jail sentence, suspended for two years, at Mold Magistrates Courts after previously admitting the three charges.
The court heard that still images found on his tablet and mobile phone included almost 100 of the most serious category.
Ninety-four still images and 56 videos were classified as category A - the most serious.
'Dark and very unpleasant'
The court was told Thomas' work had left him "lonely" with time spent away from his family, and he had got into a "trap from which it was very difficult to escape".
Judge Gwyn Jones said it had been a "dark and very unpleasant episode".
"You have lost your good character, you have caused a significant amount of pain and trauma to your family and, to put it bluntly, a significant fall from grace," he added.
Richard Williams, representing Thomas, said: "It has put a huge strain on his marriage, although to her great credit the defendant's wife has been supportive, as has his mother.
"He's an individual who knows there's problems that need to be addressed... He's a person who shows a willingness to seek out assistance in addressing what are clearly deep-rooted problems in his life."
He must also attend a rehabilitation course involving counselling and is subject to a sexual harm prevention order for seven years and was ordered to pay £85 costs and a £115 surcharge.
An NSPCC Cymru spokesman said: "Within these images are young victims of abuse and by possessing them, Thomas has fuelled the demand in this awful trade. It is not a victimless crime.
"His actions betrayed the trust placed in him by the communities he represented at Cardiff Bay and Westminster."
Helen Mary Jones, who was next on Plaid's regional list for the Mid and West Wales seat, returned to the assembly to replace Thomas in August.
Thomas had previously been MP for Ceredigion between 2000 and 2005.