Blackpool Magistrates Court heard police spotted the man on Hornby Road in Blackpool at 4am on May 26.
When officers approached Bilal Bouras, he ran off and a large kitchen knife fell from his clothing.
Bouras, 19, of South King Street, Blackpool, admitted having the knife in public.
Magistrates heard he had gone to the aid of a friend who feared he was going to be attacked.
Bouras was bailed by magistrates until July 6 for pre sentence reports.