@danon5,
(All of the following remarks are based on several Lee biographies, but principally on Freeman's
R. E. Lee, which was, of course, the "granddaddy" of Lee biographies. It was also hagiography, and made no effort to present the point of view of the Federal armies when describing operations.)
Lee resigned his commission rather late. He had taken command of the Second U. S. Cavalry in Texas when Albert Sidney Johnston left to go to California (there's an excellent biography of A. S. Johnston by William Preston Johnston, his son, who was also a "volunteer secretary" to Lee at Washington College--now Washington and Lee University--before the old General's death). He was granted leave, because of an illness of his wife (who was by that point in her life, virtually a constant invalid, with crisis episodes), and was in a hotel in San Antonio when the Federal commander in Texas, General Twigg, compounded an agreement with Ben McCulloch, and marched his troops out of the state--that was mid-February, 1861.
Lee returned to Virginia, and naturally enough, paid a call on Major General Winfield Scott, then the ranking officer in the United States Army. (When Grant was promoted Lieutenant General, it was only the second time in American history, Washington being the first, and until then only Lieutenant General in the United States Army, during the presidency of John Adams.) Lincoln had not been inaugurated, and Virginia's convention had not yet determined to secede. It is claimed by several reliable sources that Scott offered Lee a commission as Major General (which would have passed him over the heads of all other officers in Federal service, except Scott) and command of the Federal armies. Lee, if that offer were actually formally tendered, did not immediately reply. In fact, the substance of his reply was to tender his resignation upon the secession of Virginia. His rank was then Colonel. Throughout the war, Lee wore the rank insignia of a Colonel.
He was first commissioned in the Commonwealth of Virginia, and offered his services to Governor Letcher, but was soon invited to attend the Confederate Congress (which had recently arrived in Richmond), when he was offered a commission as Brigadier General in the Provisional Army of the Confederate States of America. He was subsequently fourth or fifth on the list of seven Generals produced by the C. S. Congress (General as in the highest rank available), behind A. S. Johnston, Joseph Johnston, and Pierre Beauregard (among others). He was the senior military adviser to President Davis, and apparently the only officer to whom Davis would listen, and to whom Davis would defer. Late in 1861, he was sent to take charge of an almost impossible situation in western Virginia (where forces and supplies were scanty, where many of the locals were Union men, and where he had three separate commanders to control, all of whom despised him and one another). His dismal performance there earned him the nickname "Granny Lee." He was then sent to the Carolinas and Georgia coasts to inspect and supervise the repair and construction of coastal defenses. He had the temerity to make white men dig for the construction of these defenses (which proved extremely effective), so he was then given the nickname "the King of Spades." He was not held in high esteem.
But Davis continued to listen to him and take his advice. The Confederacy always suffered from an obsession with an area defense. That meant that local officials and state Governors kept huge numbers of troops idle to defend them against unspecified threats. Lee understood how wasteful this was, and worked to correct it, although not with great success. However, he did convince Albert Sidney Johnston to strip the Gulf coast of idle troops, and that was the army which Johnston lead to the battle which became known as Shiloh. If Johnston had survived his wound, and that jackass Beauregard had not taken command, there was a real possibility that Grant's army would have been scattered before Don Carlos Buell could arrive. It would only have been a tactical victory and temporary, but if it had ended Grant's career (Lincoln was interfering and unforgiving) in early 1862, the effect would have been invaluable to the Confederacy.
In early 1862, McClellan began his peninsular campaign, and Joe Johnston felt obliged to abandon the Centreville line--leaving behind millions worth of irreplacable military supplies, including just about all the beef the CSA then currently owned. "Prince John" Magruder--so called for his love of amateur theatrics in "the old Army"--did a wonderful job at flim-flamming the Yankees, and slowing their advance, but the investiture of Richmond on the East was an unavoidable consequence. At the battle of Seven Pines, on June 1, 1862, Joe Johnston (whom i consider to have been a superior soldier to Lee, but whose clear vision made him a pessimist to whom Southerners were unwilling to listen) was wounded.
Thereafter, Lee took command of the "main army" of the Confederacy, renamed it the Army of Northern Virginia, and began the career for which he became famous. I consider him to have been highly over-rated. It was not that he did not possess the requisite skills, he just didn't seem to want to employ them effectively. Most criminal was his staff work--which was almost non-existent. Given that he made his name and his career in the old Army as Winfield Scott's chief staff engineer in Mexico, i consider his behavior to have been completely inexplicable, if not actually pathological.
He retained that command, and the respect of Davis, and continued to advise the C.S. President while he discharged his duties. After the war, until his death in 1870, he was the President of Washington College, and it was there that he related to William Preston Johnston and others his reminiscences. He did not exactly whitewash his career, but like the Anglo-Saxon Chronicles, he took no notice of his own deficiencies. He didn't need to do his own PR work though--Jubal Early, with whom Lee had always maintained rather distant relations, and who loudly and publicly criticized Lee while he served in the ANVa, became his hagiographer after the war, in a series of public speaking events lasting more than 20 years. In fact, it became Early's post war career. Lee remains one of the most fascinating figures in American history.