The attorney general of West Virginia is the chief legal advisor to the West Virginia state government and is the state's chief law enforcement officer. The office was created by Article VII, Section 1 of the first Constitution of West Virginia in 1863. Under the current state constitution (1872), the attorney general is an executive department-level state constitutional officer, along with the governor, secretary of state, auditor, treasurer, and commissioner of agriculture. The attorney general is the ex officio reporter of the Supreme Court of Appeals of West Virginia. The constitution further specifies that the attorney general shall reside in the seat of state government, Charleston, during their term of office. In Charleston, they are to maintain public records, books, and papers pertaining to their office, and perform all duties prescribed by state law. As of 2012, the attorney general receives a salary of $95,000 per year.
 The attorney general gives their written opinions and advice upon questions of law to state officials, heads of state institutions, and prosecuting attorneys. They are also responsible for all litigation on behalf of the state government and state agencies and departments. The attorney general represents the state in all claims processed by the United States Court of Claims, prosecutes civil actions as prescribed by law, enforces the state consumer, antitrust, and preneed burial statutes, and enforces the West Virginia Human Rights Act and the West Virginia Fair Housing Act. The attorney general is also an ex officio member of the Board of Public Works, Council of Finance and Administration, Public Land Corporation, West Virginia Housing Fund, West Virginia Sheriff’s Bureau, Department of Public Safety Retirement Board, Bid Suspension Review Board, State Building Commission, Commission on Charitable Contributions, Women’s Commission, Multistate Tax Compact Advisory Committee, Records Management, and Preservation Advisory Committee.
 To be eligible for election or appointment to the position, the attorney general candidate must be at least 25 years of age at the beginning of their term of service, and must have been a citizen of West Virginia for at least five years prior to their election or appointment. In 1872, when the second (and current) Constitution of West Virginia was enacted, the constitution averred that citizens residing in the state at the time of its enactment were also authorized to be elected or appointed as attorney general, regardless of the length of the residency in West Virginia. Their election can be held at any time as prescribed by law. The attorney general's term of office is four years and commences on the first Monday after the second Wednesday of the month of January following their election. If the office of attorney general should become vacant on account of death, resignation, or otherwise, the governor is authorized to select an appointee to hold that office until a successor can be elected and qualified.
 Since West Virginia became a state on June 20, 1863, it has had 34 attorneys general, of whom 33 men have held the office (the inaugural attorney general, Aquilla B. Caldwell of Ohio County, served two nonconsecutive terms). Caldwell was the first Republican to hold the office, and Joseph Sprigg of Hampshire County was the first Democrat. Darrell McGraw, who held the position from 1993–2013, is the longest-serving attorney general and served the most consecutive terms, being elected to the office five times. The current attorney general, Patrick Morrisey, began his term on January 14, 2013 and is the first Republican to hold the office in 80 years since Howard B. Lee in 1933 and the first from Jefferson County. Six attorneys general have served as Governor of West Virginia.