<?xml version="1.0"?>
<ownershipDocument>
    <schemaVersion>X0201</schemaVersion>

    <documentType>4</documentType><periodOfReport>2003-12-31</periodOfReport>
    <issuer>
        <issuerCik>0000876437</issuerCik>
        <issuerName>MGIC INVESTMENT CORP</issuerName>
        <issuerTradingSymbol>MTG</issuerTradingSymbol></issuer><reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0000904293</rptOwnerCik>
            <rptOwnerName>LUBAR SHELDON B</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>700 NORTH WATER STREET</rptOwnerStreet1>
            <rptOwnerStreet2>SUITE 1200</rptOwnerStreet2>
            <rptOwnerCity>MILWAUKEE</rptOwnerCity>
            <rptOwnerState>WI</rptOwnerState>
            <rptOwnerZipCode>53202</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
            <reportingOwnerRelationship>
<isDirector>1</isDirector><isOfficer>0</isOfficer><isTenPercentOwner>0</isTenPercentOwner><isOther>0</isOther></reportingOwnerRelationship></reportingOwner><nonDerivativeTable><nonDerivativeHolding><securityTitle><value>Common Stock</value></securityTitle><postTransactionAmounts><sharesOwnedFollowingTransaction><value>33094</value></sharesOwnedFollowingTransaction></postTransactionAmounts><ownershipNature><directOrIndirectOwnership><value>D</value></directOrIndirectOwnership><natureOfOwnership><value/></natureOfOwnership></ownershipNature></nonDerivativeHolding><nonDerivativeHolding><securityTitle><value>Common Stock</value></securityTitle><postTransactionAmounts><sharesOwnedFollowingTransaction><value>16000</value><footnoteId id="F1"/></sharesOwnedFollowingTransaction></postTransactionAmounts><ownershipNature><directOrIndirectOwnership><value>I</value></directOrIndirectOwnership><natureOfOwnership><value>By reporting person's spouse</value></natureOfOwnership></ownershipNature></nonDerivativeHolding><nonDerivativeHolding><securityTitle><value>Common Stock</value></securityTitle><postTransactionAmounts><sharesOwnedFollowingTransaction><value>48000</value><footnoteId id="F1"/></sharesOwnedFollowingTransaction></postTransactionAmounts><ownershipNature><directOrIndirectOwnership><value>I</value></directOrIndirectOwnership><natureOfOwnership><value>By the reporting person's children</value></natureOfOwnership></ownershipNature></nonDerivativeHolding></nonDerivativeTable><derivativeTable><derivativeTransaction><securityTitle><value>Share Units </value><footnoteId id="F2"/></securityTitle><conversionOrExercisePrice><footnoteId id="F3"/></conversionOrExercisePrice><transactionDate><value>2003-12-31</value></transactionDate><transactionCoding><transactionFormType>4</transactionFormType><transactionCode>A</transactionCode><equitySwapInvolved>0</equitySwapInvolved></transactionCoding><transactionAmounts><transactionShares><value>245.8728</value><footnoteId id="F4"/></transactionShares><transactionPricePerShare><value>56.94</value></transactionPricePerShare><transactionAcquiredDisposedCode><value>A</value></transactionAcquiredDisposedCode></transactionAmounts><exerciseDate><footnoteId id="F5"/></exerciseDate><expirationDate><footnoteId id="F5"/></expirationDate><underlyingSecurity><underlyingSecurityTitle><value>Common Stock</value></underlyingSecurityTitle><underlyingSecurityShares><value>245.8728</value></underlyingSecurityShares></underlyingSecurity><postTransactionAmounts><sharesOwnedFollowingTransaction><value>13734.8558</value><footnoteId id="F6"/></sharesOwnedFollowingTransaction></postTransactionAmounts><ownershipNature><directOrIndirectOwnership><value>D</value></directOrIndirectOwnership><natureOfOwnership><value/></natureOfOwnership></ownershipNature></derivativeTransaction></derivativeTable><footnotes><footnote id="F1">The reporting person disclaims beneficial ownership of shares reported herein which are owned by his wife and/or children.</footnote><footnote id="F2">The reporting person participates in the MGIC Investment Corporation Deferred Compensation Plan for Non-Employee Directors under which units corresponding to shares of Common Stock of the Issuer (&quot;Share Units&quot;) are acquired through compensation deferral.  Dividends which would have been received on shares represented by Share Units are also invested in Share Units. The Share Units are settled in cash, generally at the time the reporting person ceases to be a Director of the Issuer.</footnote><footnote id="F3">These Share Units do not have a specified dollar-denominated exercise or conversion price.  (Their value is based, on a one-for-one basis, on the price of the Issuer's common stock on the New York Stock Exchange.)  </footnote><footnote id="F4">These Share Units were acquired through compensation deferral.</footnote><footnote id="F5">These Share Units do not become exercisable or expire on a fixed date.  (Generally, the Share Units become payable at the time the reporting person ceases to be a Director of the Issuer.)  </footnote><footnote id="F6">The number of Share Units beneficially owned by the reporting person includes Share Units owned prior to August 15, 1996, which were and continue to be exempt from Section 16 of the Securities and Exchange Act of 1934.  The reporting person disclaims any waiver of such exemption.</footnote></footnotes><remarks/><ownerSignature><signatureName>Dan D. Stilwell, Attorney-in-fact</signatureName><signatureDate>2003-12-31</signatureDate></ownerSignature></ownershipDocument>

