Media playback is unsupported on your device Media caption Justin Bieber was granted bail after appearing in court via video-link from jail

Pop star Justin Bieber has appeared before a Miami court accused of driving under the influence of alcohol, marijuana and prescription drugs.

Police said the Canadian was arrested early on Thursday after racing his sports car on a Miami Beach street.

They said he did not co-operate when pulled over and also charged him with resisting arrest without violence and having an expired driving licence.

The 19-year-old singer was granted bail set at $2,500 (£1,500).

He had appeared before the judge via video-link from a Miami prison. He later left the jail escorted by officials and his personal entourage, before climbing on to the roof of a sports utility vehicle to wave to fans.

He has had several run-ins with police over the past year.

Image copyright Getty Images Image caption Justin Bieber waves after leaving the Turner Guilford Knight Correctional Center in Miami

In the latest incident, police said the singer had been racing a yellow Lamborghini against another sports car in the early hours of Thursday.

The Miami Herald reported that members of the musician's entourage had apparently used their cars to block traffic on Pine Tree Drive at 26th Street, effectively creating a drag strip.

Miami-Dade Police said the star didn't co-operate with officers at first, questioning why he had been stopped. He also had an invalid Georgia driver's licence, they alleged.

Media playback is unsupported on your device Media caption Chief Ray Martinez: "Mr Bieber smelled strongly of alcohol"

The driver of the second car - a red Ferrari - was also arrested and both cars impounded, they said.

The other driver was later named as an R&B singer known as Khalil. He was also set bail by the court.

"During the investigation Mr Bieber made statements that he had consumed some alcohol, that he had been smoking marijuana and consumed some prescription medication," said Miami Beach police chief Raymond Martinez.

"They were starting from a stop position and they were accelerating to a high rate of speed, going almost double the speed limit... in that area."

The arrest report said the singer "had slow deliberate movements" and a look of "stupor" when the officer told him to step out of the Lamborghini.

The two men were first taken to Miami Beach police station and later transferred to a Miami-Dade County jail before their court appearance.

The street where police say Mr Bieber was racing is a residential area in mid-Miami Beach.

Image copyright Reuters Image caption A Lamborghini, right, and a Ferrari were both impounded by Miami police

Image copyright Miami Beach Police Image caption R&B singer Khalil was allegedly driving the red Ferrari

Image copyright AP Image caption A police van believed to be carrying Justin Bieber arrived at a county jail

Small apartment buildings are along one side of the street and on the other side are a high school, a youth centre, a golf course and a fire station.

The arrest came a week after Mr Bieber's home in Los Angeles was searched by police following allegations he had thrown eggs at his neighbour's house.

He was accused of causing significant damage to the property. One member of his entourage was arrested for alleged drug possession following the search.

Last year, the singer was asked to remove graffiti he had left on the wall of a hotel in Australia. That came a month after he was charged in Brazil over a similar offence.

In 2012 he faced accusations of reckless driving, although prosecutors declined to press charges.

Justin Bieber lives in a gated community in Calabasas, about 30 miles north-west of central Los Angeles.