A Rikers Island inmate who was brought to Brooklyn for a court appearance tricked a corrections captain by giving a fake name — and was allowed to go free.

Layquan Johnson, 22, waltzed out of Brooklyn Supreme Court Tuesday night after duping the captain with the long shot ploy.

He had had been brought there from Rikers to appear before a judge over a shooting from last Dec. 9, in which he shot a rival in the leg in Crown Heights police sources said.

While inside the court, Johnson provided a fake name to a Department of Correction captain, who took the bait hook, line and sinker and unwittingly released him from custody — letting the violent criminal out onto the street.

Police are now looking to re-arrest him.

Click for more from the New York Post.