A rapper has told a court he was forced to carry a gun by a man from whom he bought cannabis, who shoved the weapon in his face and made threats against him and his mother.

Jyrelle O’Connor, 20, known as Loski, whose music has attracted more than 12m hits on YouTube, gave evidence at Croydon crown court on Monday. He denies possession of a firearm with intent to endanger life and other related charges.

O’Connor was arrested on 9 April last year after police found a small loaded revolver in a sock underneath the front passenger seat of an Uber he was travelling in, which he had booked using a false name.

The rapper told the court that on 8 April he had arranged to meet a cannabis dealer he had contacted on Snapchat to purchase 14 grams of cannabis. He said he had purchased cannabis from the dealer, known as D, more than 10 times previously.

He claimed that once he got into a car with the dealer at a prearranged meeting place in north-west London, things started to go wrong and he believed he was being kidnapped. O’Connor told the court that the door of the car was locked and he panicked. “He put a gun in my face, I was panicking a lot. He said he knew where I lived and where my mum lived. With a gun in your face there’s not really a way out of it.”

He told the court the dealer told him “I need you to hold something for me” and handed him a gun wrapped in tissue, which the dealer told him he had to hold on to until the next day before delivering it to a drop-off point.

O’Connor, who was living in Gerrards Cross, south Buckinghamshire, at the time of the alleged offences, told the court he had witnessed a lot of violence in his childhood and had moved from his home in Kennington, south London, to live with his grandmother in Borehamwood, Hertfordshire, after having a gun held against his head by a group of older boys he did not know when he was 12 years old.

“When I told the police about the gun to my head nothing really happened, so I didn’t feel they could help in any way,” he told the court.

He said by the time he was 14 older boys forced him to get involved in what he described as “country” drug dealing, predating county lines. “We all had to go up to the country to sell drugs. If you don’t agree with what’s going on, you can’t not do what you’re told. You don’t have a choice.”

He told how on 4 September 2014 he was arrested in a car in Andover, Hampshire, in possession of heroin and crack cocaine with intent to supply. He said he had been told to “bank” the drugs - hide them inside him - but he said he was too scared to do that and kept them in his underpants instead where police found them.

“Because I lost the drugs I was told that the only way to clear the debt was to hold more drugs. They said it was my fault because I didn’t bank the drugs.”

After two spells of approximately a year in youth custody for drug and weapons-related offences, he began to succeed as a drill artist. He had been writing and performing rap music since the age of 11, but after his second period of imprisonment his music began to take off, he said.

He told the court that in his music he was reporting on incidents of crime he saw around him in south London rather than becoming involved in committing the crimes himself.

“Drill music is rapping about drugs, knives, violence – it’s reporting on what’s going on in the area. It started in Chicago but UK took the sound to try to make it their own,” he said.

“In drill you antagonise people, you make it sound as outrageous as possible, you take something that someone said and make it even better. Everyone wants to have the best drill song, it’s a common genre of music. I have said certain things that I haven’t seen but I have heard. Yes, this is what’s really going on.

“I have to sound as real as possible otherwise you don’t get far. It’s all about YouTube views. If you say something, everyone talks about you and you get more views. Rap doesn’t always have to make sense, it has to rhyme. I don’t look scary so I have to say something that looks more than I am.”

O’Connor told the court he signed to Since ’93, a label within Sony, and released a mixtape, Call Me Loose. One track, Forrest Gump, attracted 12m views on YouTube; another, Money & Beef, drew 2-3m views.

From 18-25 March last year he embarked on a tour across the UK. “Drake came to my show on 25 March,” he told the court, referring to the Canadian hip-hop artist. “Drake to me is the biggest rapper in the world right now. He put out a statement saying my music was part of his inspiration. When he came to my show it was a big deal, he was right next to all my family.”

At the time of his arrest, O’Connor said, he had a lot of projects lined up, including a track he had recorded with Stormzy.

The case continues.