The Arduino IDE and AVRDUDE...

Let's put all this together and explore how the Arduino IDE works with AVDUDE. AVRDUDE is a stand-alone program which comes bundled with the Arduino software package. AVRDUDE is designed to be used with the CLI (Command Line Interface) and the Arduino IDE sends commands to AVRDUDE in the same way using its own "shell". The picture below shows the various ways that AVRDUDE can be used.

Here's a reminder of the type of upload/programming options available on the Arduino IDE and what they do:

Upload Button Uses the "default" protocol set in the IDE's "preferences.txt" file or the programmer/protocol set in the IDE's "boards.txt" file if different. If the "upload.protocol=" entry is ommitted from the the target AVR's "boards.txt" entry, the selected "Programmer" will be used instead and the Upload action will become the same as the "Upload Using Programmer" option. Example below.
The "Upload Using Programmer" option on the "File" menu Uses the programmer type selected from the IDE's "Tools/Programmer" list to program directly to the device/board without the use of a "bootloader" Overrides the "default" or "boards.txt" protocol. This also overwrites the bootloader, if present
The "Burn Bootloader" option on the "Tools" menu Uses the programmer selected in the IDE's "Tools/Programmer" list to "burn" a bootloader file to the device/board in question. Fuses are also set/reset using this option. If the "boards.txt" entry does not specify a bootloader, just the fuses will be set/reset.

Default Arduino Uno "boards.txt" entry Arduino Uno "boards.txt" entry altered to use the
selected "Programmer" as the  "Upload" tool
uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard
uno.name=Arduino Uno
uno.upload.maximum_size=32256
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard
"Upload" Button will use the Serial Port (arduino protocol) "Upload" Button will use the selected programmer

"Upload" Button:

When you click the "Upload" button on the IDE, the software compiles your sketch into a HEX file which contains the binary code for the AVR and then sends a command to AVRDUDE which takes over and performs the programming task. Here is the command which the Arduino IDE sends to AVRDUDE for the Blink sketch upload using the serial port (<path> replaces the lengthy file paths):

avrdude -C  <path> avrdude.conf -v -v -v -v -p atmega328p -c arduino -P\\.\COM6 -b 115200 -D -U flash:w: <path> Blink.cpp.hex:i

avrdude The AVRDUDE program (avrdude.exe)
-C <path> The file path to the avrdude.conf file
avrdude.conf The name of the configuration file
-v -v -v -v Enable Verbose output, multiple -v = more Verbose output (you see more output from AVRDUDE)
-p atmega328p The target AVR
-c arduino The programming protocol (device USART using the device serial port)
-P\\.\COM6 The Serial Port for the target device USART
-b 11500 The baud rate used to communicate with the USART on the target device
-D Disable erasing of Flash memory (so we don't overwrite the bootloader)
-U flash:w: Read the HEX file and write it to Flash memory
<path> The file path to the HEX file to be uploaded
Blink.cpp.hex:i The HEX file created by the Arduino IDE (i = Intel HEX)

"Upload Using Programmer":

When you select this option from the "File" menu, the programmer selected in the "Tools/Programmer" menu list will become the programming tool for "uploading" the sketch. A command similar to this will be sent to AVRDUDE (any code already on the AVR including the bootloader will be overwritten):

avrdude <path> avrdude.conf -v -v -v -v -p atmega328p -c stk500v1 -P\\.\COM6 -b 19200  -U flash:w: <path> Blink.cpp.hex:i 

avrdude The AVRDUDE program (avrdude.exe)
-C <path> The file path to the avrdude.conf file
avrdude.conf The name of the configuration file
-v -v -v -v Enable Verbose output, multiple -v = more Verbose output (you see more output from AVRDUDE)
-p atmega328p The target AVR
-c stk500v1 The programming protocol (in this case for the ArduinoISP)
-P\\.\COM6 The port that the programmer is on (in this case it's an ArduinoISP on COM6)
-b 19200 The baud rate used to communicate with the programmer
-U flash:w: Read the HEX file and write it to Flash memory
<path> The file path to the HEX file to be uploaded
Blink.cpp.hex:i The HEX file created by the Arduino IDE (i = Intel HEX)

"Burn Bootloader":

This option uses the currently selected "programmer" and burns the associated bootloader onto the AVR. All existing code is overwritten and the fuses are set/reset. If no bootloader is specified in the "boards.txt" file for the target AVR, only the fuses will be set/reset. Two passes are made:

First pass with unlock bits and set fuses (unlocks the lock bits and sets/resets the fuses):

avrdude <path> avrdude.conf -v -v -v -v -p atmega328p -c stk500v1 -P\\.\COM6 -b 19200 -e -U lock:w:0x3F:m -U efuse:w:0x05:m -U hfuse:w:0xDE:m -U lfuse:w:0xFF:m -U flash:w: <path> chosen-bootloader.hex:i 

Second pass with lock bits:

avrdude <path> avrdude.conf -v -v -v -v -p atmega328p -c stk500v1 -P\\.\COM6 -b 19200 -U lock:w:0x0F:m

avrdude The AVRDUDE program (avrdude.exe)
-C <path> The file path to the avrdude.conf file
avrdude.conf The name of the configuration file
-v -v -v -v Enable Verbose output, multiple -v = more Verbose output (you see more output from AVRDUDE)
-p atmega328p The target AVR
-c stk500v1 The programming protocol (in this case for the ArduinoISP)
-P\\.\COM6 The port that the programmer is on (in this case it's an ArduinoISP on COM6)
-b 19200 The baud rate used to communicate with the programmer
-e Erase the Flash memory of the AVR
-U lock:w:0x3F:m Set the "lock" fuse bits to the "unlock" value
-U efuse:w:0x05:m Set the "extended" fuse bits
-U hfuse:w:0xDE:m Set the "high" fuse bits
-U lfuse:w:0xFF:m Set the "low" fuse bits
-U flash:w: Read the bootloader HEX file and write it to Flash memory
<path> The file path to the HEX file to be uploaded
chosen-bootloader.hex:i The bootloader HEX file(i =  Intel HEX)

The "lock" bits are used to protect the Flash memory and/or EEPROM memory and therefore we need to "unlock" the memory if we want to write to it. You do not have to lock the memory for normal use unless you are using a bootloader.

The second pass merely applies the "lock" bits that were "unlocked" during the first pass. Again, you do not have to set the lock bits for normal use.

Depending on the device being used, there are a number of different ways of writing the code onto the device as follows:

USART in SPI Mode Universal Synchronous/Asynchronous Receiver Transmitter (not available on all AVRs)
SPI Serial Peripheral Interface (available on most AVRs)
Parallel Programming Mode Not available on all AVRs and not dealt with in these tutorials
High Voltage Programming Not dealt with in these tutorials

So, what does this all mean?;

Put simply, USART in SPI mode is the method used by the Arduino boards such as the Uno to upload sketches when a bootloader is present on the device. It is the job of the bootloader to prepare the device for data transfer using the on-chip USART via the Tx and Rx serial port. On the Arduino Uno the USB port is connected to a USB USART on the board which in turn passes the data to and from the AVR. This mode is only used to write data into the memory of the device i.e. your sketches.

SPI is the real programming method and it requires a programmer such as the ArduinoISP or AVRISP MKII to communicate the commands and data to and from the AVR. SPI uses 4 signals called RESET, SCK, MISO and MOSI connected as follows (The Arduino Uno is given as an example):

Signal Meaning Purpose ATmega328 pin Arduino pin
RESET RESET RESET signal for device 1 NA
SCK Serial ClocK Used to "Clock" data in/out of device 19 13
MISO Master Input/Slave Output Data I/O for device 18 12
MOSI Master Output/Slave Input Data I/O for device 17 11

SPI is the method used to program bootloaders onto a device (if applicable) and set/reset fuses etc.