versagen
to fail
To not perform the expected function or service; to not work as intended.
Mitten auf der Autobahn hat der Motor versagt.
The engine failed in the middle of the highway.

to fail / to deny
Loading your saved state.
to fail
To not perform the expected function or service; to not work as intended.
Mitten auf der Autobahn hat der Motor versagt.
The engine failed in the middle of the highway.

'Versagen' (to fail/to deny) is an inseparable verb. The prefix 'ver-' here, as with many other verbs such as 'verlieren' (to lose) and 'vergessen' (to forget), points to a negative result or a failure.
Er hat sich bei der Adresse verschrieben.
He wrote the address incorrectly.
The grammar helps distinguish the meanings. If 'versagen' (to fail) appears without an object, it means 'to fail' or 'to stop working.' If it appears with a dative and an accusative object, it means 'to deny/refuse.'
Die Bremsen haben versagt.
The brakes failed.
In the meaning 'to refuse/deny,' 'versagen' needs two objects: a person in the dative (the person to whom something is denied) and a thing in the accusative (what is denied).
Die Eltern versagten ihrem Sohn die Erlaubnis, auf die Party zu gehen.
The parents denied their son permission to go to the party.
The expression 'die Stimme versagt' (one's voice fails) is a fixed unit. The person who can no longer speak is often expressed with a dative pronoun.
Mitten in ihrer Rede versagte ihr die Stimme.
In the middle of her speech, her voice failed her.
to work
'funktionieren' and 'versagen' both describe whether something delivers the expected performance. 'funktionieren' means that a device, a plan, or a system works and fulfills its purpose. 'versagen' is the opposite: something does not work out or does not deliver the expected performance. With people, 'versagen' can also mean that someone fails to complete a task. The words can be confused because both are often used in situations where a result is expected. Remember: if it works out, it 'funktioniert'. If it does not work out or fails, it 'versagt'.

In der Prüfung versagte Max, obwohl er viel gelernt hatte.
Max failed the exam, even though he had studied a lot.
Mein Handy funktioniert wieder, seit ich es neu gestartet habe.
My phone works again since I restarted it.