The assault occurred on The Loan in South Queensferry at around 1.30am yesterday.
Police investigating the incident near the Scotmid store have appealed for witnesses to come forward.
The victim is being treated at Edinburgh Royal Infirmary.
Detective Inspector Raymond Brown, from Police Scotland, said: "This was a violent assault where the male received significant injury and an investigation is ongoing. We are appealing for anyone who was in or near The Loan around 1.30am and who witnessed a disturbance to contact police immediately. We are also keen to trace a car that was seen in the area at the time."
Chief Inspector Mark Rennie said that at this stage it appeared to be an isolated incident.