There are 4 different methods of braking a motor that VFDs can use. Two of them, Dynamic Braking (DB) and DC Injection Braking (DCIB), are included in most standard VFDs.
Charles Cowie already described the Dynamic Braking wherein the kinetic energy in the rotating load is transmuted into electrical energy and pulled off of a motor by making it a generator, then is converted again into heat energy in a resistor (or distributed out to other inverters on the same DC bus), removing it safely from the motor.
In DCIB, the transistors are fired in a pattern that pumps DC into one set of windings in the stator, setting up a now stationary magnetic field. As the rotor bars pass through that field, they create a counter-rotating magnetic field that opposes the direction of rotation and brings the motor to a stop. In this method, the kinetic energy of the rotating mass is absorbed by the motor rotor and stator, so it has negative consequences if over used.
The third braking method is called Flux Braking (FB) but requires the use of a good quality Vector type VFD. This is because in Vector Control, the VFD can calculate and separate the flux producing current from the torque producing current, which is one reason why Vector control can be so much more accurate. The normal goal in doing this is to give the motor only JUST ENOUGH flux current to excite the windings without overheating them, reserving more of the available current for producing torque. But in Flux Braking, the VFD turns the motor into a generator just as in Dynamic Braking, but instead of pumping that energy into external resistors as heat, it purposely consumes that energy by increasing the flux current into the motor. So what it is doing is using the MOTOR as the braking resistor. FB therefor has similar possible negative consequences seen in DCIB, but does not require the external resistors like DB. Not all VFDs sold as "Vector Drives" are capable of this, it takes a true Flux Vector Control capability drive.
The fourth braking method, Line Regenerative Braking, requires another different type of VFD, called an "Active Front End" (AFE) topology. Instead of the simple passive diode bridge rectifier, the VFD has another set of active transistors on the front-end converter section, called a "Line Inverter" (as opposed to a "Load Inverter"). So again, taking the regenerated energy off of the motor, the Line Inverter then pumps that energy BACK into the line side to be used by other AC loads in your system. Like DB and FB it removes the energy from the motor as a generator, but instead of "wasting" it in a resistor or into the motor flux, it is recaptured for use elsewhere. The downside of this type is that the VFD is significantly more expensive because you are using two inverters back-to-back. It's not quite twice the price of a standard VFD, but it is a lot more money. However if your duty cycle is high and/or you need to provide continuous or near continuous braking, this method provides a major benefit.