Rapper Lil Nas X has pleaded not guilty to injuring a police officer and resisting arrest after he was detained last week while wandering the streets of Los Angeles naked.

The rapper, whose legal name is Montero Lamar Hill, is facing three felony counts of battery with injury to a police officer and one felony count of resisting arrest. If convicted, he could face up to five years in prison.

Police said when they responded to a call about a nude man wandering the streets, the Grammy-winning artist charged at them.

He was taken to the hospital for a possible overdose after the incident, which happened in the early hours of Thursday, authorities said.

The 26-year-old artist was arraigned in a Los Angeles courthouse on Monday. His bail was set at $75,000 (£55,456), according to CBS, the BBC's US news partner.

Unverified videos and images published by TMZ appear to show the rapper wandering the streets before the police altercation unfolded. They show the Old Town Road singer dancing along a Los Angeles street in Studio City, wearing just white underwear and white cowboy boots.

Later, he was seen completely nude and walking in the center of a road. Footage published by TMZ shows him approaching a passing car as he raps lyrics from Kayne West's song 'Monster'.

His white cowboy boots, meanwhile, were apparently picked up by a passerby who listed them on eBay with a price tag of $10,000.

LA police reported that they responded to reports of a nude man walking along Ventura Boulevard. He charged at officers when they got to the scene, officer Drake Madison stated.

Three officers were injured while trying to take the rapper into custody. Los Angeles County District Attorney Nathan Hochman emphasized, 'Attacking police officers is more than just a crime against those individuals but a direct threat to public safety.'

Lil Nas X is expected to release his much-anticipated second studio album, Dreamboy, later this year and has recently teased new music on social media. Despite moments of controversy, including winning Grammy Awards for his groundbreaking collaborations, his recent legal troubles have illuminated the complexities of celebrity culture and accountability.