meaning of "Let the devil take the hindmost"

What is the origin and/or meaning of “let the devil take the hindmost?”

It means as much as ‘put yourself first and don’t care about other people’. It’s a reflection of a devil-may-care attitude.